Getting instances

The Get-CimInstance command is used to execute queries for instances of WMI objects. For example:

Get-CimInstance -ClassName Win32_OperatingSystem 
Get-CimInstance -ClassName Win32_Service 
Get-CimInstance -ClassName Win32_Share 

A number of different parameters are available when using Get-CimInstance. The command can be used with a filter:

Get-CimInstance Win32_Directory -Filter "Name='C:\Windows'" 
Get-CimInstance CIM_DataFile -Filter "Name='C:\Windows\System32\cmd.exe'" 
Get-CimInstance Win32_Service -Filter "State='Running'" 

When returning large amounts of information, the Property parameter can be used to reduce the number of fields returned by a query:

Get-CimInstance Win32_UserAccount -Property Name, SID 

The Query parameter can also be used, although it is rare to find a use for this that cannot be served by the individual parameters:

Get-CimInstance -Query "SELECT * FROM Win32_Process" 
Get-CimInstance -Query "SELECT Name, SID FROM Win32_UserAccount" 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.52.188