Select WMI

I’ve been helping out on some WMI and PowerShell issues in the forums at As I was working on a problem I ended up taking a slight detour to address an issue that has always bugged me. When I run a command like this:

PowerShell wants to return system classes as well.

The work around has been to pipe the original expression to Select-Object and re-selecting the properties I want. This seems like an unnecessary step. Now, depending on the class I could simple return all WMI objects and then use Select-Object. But I should be able to take advantage of early filtering and use Get-WmiObject as it was intended. So I wrote a function called Select-WMI that will take any WMI-looking object and return the non system properties.

I assumed you would run it as part of a pipeline. Now, I can more easily get the information I’m after.

The function will also work to bypass PowerShell’s default formatting for WMI objects, making it easier to see all the properties.

But I took this one step further. There are times when all I want are properties that have a value. So Select-WMI has a –Populated parameter so that only populated properties are displayed.


Now, you’ll only really need this when using the WMI cmdlets. In PowerShell v3 and later you can use Get-CimInstance which by default does not display the system properties.

[updated March 15, 2014]