Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

The Voice of the DBA

Steve Jones is the editor of SQLServerCentral.com and visits a wide variety of data related topics in his daily editorial. Steve has spent years working as a DBA and general purpose Windows administrator, primarily working with SQL Server since it was ported from Sybase in 1990. You can follow Steve on Twitter at twitter.com/way0utwest

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

Get-WMIObject

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

Get-CIMInstance

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.


Filed under: Blog Tagged: career, powershell, syndicated

Comments

Leave a comment on the original post [voiceofthedba.wordpress.com, opens in a new window]

Loading comments...