20.3. PowerShell's WMI Support
Now that we have had all the theory behind us, we can move to something real and tangible. What does it take to work with WMI objects from within PowerShell? The standard approach before PowerShell was to use the scripting API exposed as a set of COM objects. While writing COM client code is possible in every language, the typical WMI client code was written in VBScript, as that was easiest to do. The code involved getting an instance of the CIM object manager and giving it a WQL query. The result was a collection that was enumerated using a standard For Each loop that works in the same way as the foreach loop does in PowerShell. Just to get a taste of what the code is like, let's take a quick look at the winword_pid.vbs ...
Get Pro Windows PowerShell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.