Cim or Wmi

Welcome Forums General PowerShell Q&A Cim or Wmi

This topic contains 2 replies, has 3 voices, and was last updated by

3 years, 1 month ago.

  • Author
  • #34695

    Points: 0
    Rank: Member

    Should I use Get-CimInstance or Get-WmiObject?
    Using Visual Studio Code with the powershell extension – I get a warning when using Wmi that I should use Cim. But using Sapien Powershell Studio 2015 the intellesense stuff doesn't bring up the list of classes when I use Cim, but it does when I use Wmi, which makes it easier when i'm looking for what I want. I've also watched some fairly recent powershell videos on and pluralsight where Wmi is still being used.

  • #34696

    Points: 1
    Rank: Member

    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.

    Introduction to CIM Cmdlets

  • #34701

    Points: 0
    Rank: Member

    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

The topic ‘Cim or Wmi’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort