Discovering CIM/WMI methods and parameters

As you’ve probably gathered I spend a lot of time working with, and investigating, CIM (WMI) classes. CIM and WMI will be treated as synonymous for these articles.

If you want to discover the methods available on a CIM class you can do this:

$class = Get-CimClass -ClassName Win32_Process

If you want to drill down into an individual method you then have to do this:


We end up with a two stage process. Firstly discover the available a methods and then discover the parameters on the method.

In a busy session this can turn into a lot of typing. You can short-circuit some that if you using the Get-CimMethodParameter from the CIM Utilities modules that can be downloaded from

To my mind it only supplies an answer to the last part of the problem. There is a hidden method – Get-CimMethod – that does the first step but as its not published it doesn’t help us.

I decided that its time to re-write the module to work the way I want.  This provides an opportunity to go over the functionality of Get-CimClass, Advanced functions and modules.

To define my problem:

I want a cmdlet that:

  • provides a list of methods on a WMI class
  • provides the parameters of a specific method
  • the standard output of Get-CimClass is acceptable
  • work with any namespace
  • work with remote machines
  • not concerned about pipeline input at this stage (may add later)
  • not concerned about outputting parameters as a hash table ( though may add later)

I’ll start with a simple function to perform the first two requirements.

function Get-CimMethod {
param (



if ($methodname)
$class = Get-CimClass -ClassName $classname
Get-CimClass -ClassName $classname | select -ExpandProperty CimClassMethods


I decided to save this as a psm1 file (module file) and called the module CimInvestigation.

In PowerShell 3 & 4 the module autoloads so I can do this:

Get-CimMethod -classname Win32_NetworkAdapter

Get-CimMethod -classname Win32_NetworkAdapter -methodname setpowerstate

Next time I’ll turn this into more of an advanced function with some validation and error checking

This entry was posted in CIM, PowerShell and WMI, PowerShell V3, PowerShell v4. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s