Powershell in a Month Day 14 – WMI

This is part of my Powershell Challenge, to learn more about PowerShell (PoSh) using the Learn Windows Powershell 3 in a Month of Lunches book by Don Jones.

Day 14 introduces us to Windows Management Instrumentation (WMI). Since many people might not be familiar with WMI, the chapter spends a little time trying to help you understand what WMI is.

I know what it is, I hate it, and I agree, it’s a PIA. It’s a mess, it’s inconsistent, and I’m not surprised the Powershell barely integrates with it. As with the cmdlets, this shows that there are the WMI cmdlets and the newer CIM cmdlets. The old ones like


are somewhat deprecated. They work, but no development is being done. Instead, we need to use


That makes sense to me and I understand it. With no legacy work, I don’t think I have any issue with using Get-CIMInstance, though I do hate the idea of querying the WMI spaces. They’re a mess and nothing is intuitive.

gwmi -class win32_bios -computer localhost,JollyGreenGiant | format-table @(l=’Host’;e={$_.__SERVER}

There’s more to the table, but that’s all I typed in to test. I did a few more queries, with this and Get-CIMInstance to practice, but most of this chapter is really just understanding how WMI is organized to look for things and then formatting the results. Easy enough to do, a little boring, but good practice with expressions.

The lab was annoying, mostly because it’s asking you to figure out which WMI classes to query. I googled around for some, and found them, but mostly this is annoying. I can certainly see where it’s handy to understand how WMI queries work, but like most people, I prefer to avoid them.

Short chapter, easy, and good practice formatting things.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , , . Bookmark the permalink.

1 Response to Powershell in a Month Day 14 – WMI

  1. Pingback: The Powershell Challenge | Voice of the DBA

Comments are closed.