O'Reilly logo

Pro Windows PowerShell by Hristo Deshev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required