#PSTip Get all WMI classes with methods

Note: This tip requires PowerShell 2.0 or above.

When working with WMI and PowerShell, I often find it necessary to quickly generate a list of methods available in a WMI class. One way to do this is to examine the WMI class meta data. Let us see how:

Get-WmiObject -Query 'Select * From Meta_Class WHERE __Class LIKE "win32%"' |
Where-Object { $_.PSBase.Methods } |
Select-Object Name, Methods

This will list all Win32 WMI classes with methods.

In Windows PowerShell 3.0, the same can be done using:

Get-CimClass -ClassName win32* | where {$_.CimClassMethods} | select CimClassName,CimClassMethods

or

Get-CimClass -ClassName win32* | where CimClassMethods -ne $null  | select CimClassName,CimClassMethods

About the author: Ravikanth C

Ravikanth is the founder and editor of the PowerShell Magazine. He is also a PowerShell MVP who works at Dell Inc. He blogs at http://www.ravichaganti.com/blog and you can follow him on Twitter @ravikanth.

Related Posts