Invoking WMI class methods
WMI methods enable you to execute different activities on a system. PowerShell provides the ability to hook onto these methods to perform different actions using the invoke-cimmethod
cmdlet. In order to determine what methods are available for use in a WMI class, you can leverage the get-cimclass
cmdlet, with the optional –class
parameter pointing to a WMI class. You then can pipe those results to the selection criteria of | select -ExpandProperty CimClassMethods
. This will display all the methods and properties for those methods in that WMI class. This will help you expose what methods are available for a particular class.
To leverage the get-cimclass
cmdlet to see the methods in the win32_process
class, you can do the following:
get-cimclass win32_process | select –ExpandProperty CimClassMethods
The output of this command is shown in the following screenshot:
There are two popular ways to utilize the invoke-cimmethod
cmdlet. The first is to use the...