There are two cmdlets you can use to retrieve WMI data: the older Get-WmiObject cmdlet, and the more modern Get-CimInstance cmdlet. When used locally, they both behave very similarly. When used remotely, however, the differences can be drastic.

Here are two example calls that both retrieve information about file shares from a remote system (make sure you adjust the computer name):

Get-WmiObject -Class Win32_Share -ComputerName sr0710
Get-CimInstance -ClassName Win32_Share -ComputerName sr0710

(both calls require local Administrator privileges on the target computer, so you may want to add the parameter -Credential and submit a valid account name if your current user does not meet these requirements)

While Get-WmiObject always uses DCOM as a transport protocol, Get-CimInstance uses WSMan (a webservice-type of communication). Most modern Windows systems support WSMan, but if you need to contact older servers, they may only respond to DCOM, thus Get-CimInstance may fail.

Get-CimInstance can use session options, however, that provide great flexibility, and allow you to choose the transport protocol. In order to use DCOM (just like Get-WmiObject), do the following:

$options = New-CimSessionOption -Protocol Dcom
$session = New-CimSession -ComputerName sr0710 -SessionOption $options
$sh = Get-CimInstance -ClassName Win32_Share -CimSession $session 
Remove-CimSession -CimSession $session

Twitter This Tip! ReTweet this Tip!