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

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.

PowerShell

1

2

3

4

5

6

7

WMI(Not recommended)

(Get-WmiObject-ClassNamewin32_operatingsystem).LastBootUpTime

20150522095242.375199+120

CIM(Recommended)

(Get-CimInstance-ClassNamewin32_operatingsystem).LastBootUpTime

22May201509:52:42

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.