Powershell Best Practice #4: Use CIM cmdlet (not WMI cmdlet)

By | May 22, 2015

Best Practice: It is recommended to use CIM cmdlets, not WMI cmdlets.


WMI cmdlets are considered obsolete but if you stil use legacy PowerShell v1/2 you could use them.
Since Powershell v3 CIM new cmdlets are available.

Microsoft is not spending time on WMI cmdlets, it means that no additional development or improvement is expected.
However, the positive point of WMI cmdlets is the backwards compatibility with older PowerShell versions.

CIM and WMI use the same WMI backend but the way of communication is different.

CIM cmdlets

  • DCOM : used when querying the local computer
  • WS-MAN : used for ad hoc connections to remote computer
  • DCOM or WS-MAN : used for session-based connections to remote computers

WMI cmdlets

  • Session-based connections not supported
  • Support only ad hoc connections over DCOM

A great benefit of CIM is the use of WSMAN (WS-Management) protocol for remote access.
Performing queries WMI using RPC/DCOM was not very firewall friendly, it is now easier using WSMAN protocol.
DCOM uses RPC and this protocol requires special firewall exceptions.

Microsoft has implemented the WS-Management standard in Windows Remote Management (WinRM).

Note: CIM tend to return directly the correct Datetime format (no more conversion needed).


Leave a Reply

Your email address will not be published.