PowerShell for Windows Admins

Feb 28 2011   1:32PM GMT

WMI metadata

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

 

We normally use WMI to either return information about our systems

Get-WmiObject -Class Win32_Process | sort KernelModeTime -desc | Format-Table Name, KernelModeTime –AutoSize

or to perform some action

Get-WmiObject -Class Win32_Process -Filter "Name=’notepad.exe’" | Remove-WmiObject

One hidden facet of WMI are the qualifiers. These contain the metadata about the class.

Get-WmiObject -List Win32_Process | select *

shows them tucked away near the end of the data

Get-WmiObject -List Win32_Process | select -ExpandProperty Qualifiers

shows them in more detail. Unfortunately this doesn’t give us the full set of information.  We need to add the –amended parameter

Get-WmiObject -List Win32_Process -amended | select -ExpandProperty Qualifiers

This enables us to see the description which in this case is

Get-WmiObject -List Win32_Process -amended | select -ExpandProperty Qualifiers | Where {$_.Name -eq "Description"}

We can then get the actual text of the description which is held in the Value property.

Get-WmiObject -List Win32_Process -amended | select -ExpandProperty Qualifiers | Where {$_.Name -eq "Description"} |  Format-Table value -wrap

The Win32_Process class represents a sequence of events on a Win32 system. Any sequence consisting of the interaction of one or more processors or interpreters, some executable code, and a set of inputs, is a descendent (or member) of this class.
Example: A client application running on a Win32 system.

We can simplify the code to

((Get-WmiObject -List Win32_Process -amended).Qualifiers | Where {$_.Name -eq "Description"}).Value

This is useful if you have a set of classes you want to investigate and need to know what they do

Get-WmiObject -List *print* | sort name |

foreach {

"`n$_.Name"

(( Get-WmiObject -List $_.Name -Amended ).Qualifiers | Where {$_.Name -eq "Description"}).Value

}

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: