2

#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
Filed in: Columns, Tips and Tricks Tags: , ,

2 Responses to "#PSTip Get all WMI classes with methods"

  1. How can you make the output expand where there are no ellipses?
    {StartService, StopService, PauseService, ResumeService…}

  2. You can change the $FormatEnumerationLimit preference variable. (The default value is 4.)

    $FormatEnumerationLimit = 1000

    Get-CimClass -ClassName win32* | where CimClassMethods -ne $null | ft CimClassName,CimClassMethods -wrap -auto

Leave a Reply

Submit Comment

© 1982 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: