header image

Improving CIM/WMI method discovery

Posted by: | March 27, 2014 | No Comment |

I recently showed how to create a function that could be used to simplify the use of Get-CimClass.

In this version I’ve added some features:

– parameter validation

– namespace

– try-catch round getting the class information.

This turns the code into:

function Get-CimMethod {
param (

[string]$namespace = ‘root/cimv2’,



$class = Get-CimClass -Namespace $namespace -ClassName $classname -ErrorAction Stop
  Throw "Class: $classname NOT FOUND"

if ($methodname)


The module and function can be used like this:

Import-Module CimInvestigation -Force
Get-Command -Module CimInvestigation
Get-CimMethod -classname Win32_Process
Get-CimMethod -classname Win32_Process -methodname Create
Get-CimMethod -classname Win32_Process -methodname Create -namespace root/cimv2

under: PowerShell and CIM, PowerShell and WMI, PowerShell V3, PowerShell v4