Should I use Get-CimInstance or Get-WmiObject?
You should use Get-CimInstance if you can. It's not always feasible however. Get-CimInstance relies on WinRM. So if you do not have WinRM enabled in your environment, you have to stick with Get-WmiObject. Get-CimInstance is what MS is developing going forward. One of the beautify things about Get-CimInstance is that is strives to more heterogeneous usage, whereas Get-WmiObject is only usable against Windows Platforms.
Here is a nice blog comparing the two.
This deserves a longer answer so I'll put up a blog post on it. Short answer is that the CIM cmdlets are the preferred way forward. The WMI cmdlets are unlikely to be developed any further – in fact the Get-WmiObject help files states 'Starting in Windows PowerShell 3.0, this cmdlet has been superseded by Get-CimInstance.'
As stated above the CIM cmdlets use WSMAN (you need the WinRM service running but you don't need to have enabled PowerShelll remoting – modern Windows server OSs have it enabled anyway) though can drop back to DCOM if needed. WMI cmdlets use DCOM
The CIM cmdlets also unravel dates into a usable format
Invoke-CimMethod uses a hash table for method parameters so avoids the order issue that Invoke-WmiMethod has.
One draw back to the CIM cmdlets is that you can't access ammended data on the WMI class – but thats not something done frequently
Get-CimClass is great for discovery. The ability to refresh an object is useful.
I always recommend, and use, the CIM cmdlets these days. if you see material recommending the WMI cmdlets contact that author and suggest he brings his material up to date
You must be logged in to reply to this topic.