Get-WMIQualifierValue (revisited)
An updated version of my Get-WMIQualifierValue function. With this version you can query remote computers, specify the NameSpace of the class and also specify a property name to get just its values instead of all properties.
Sample Usage:
Get-WMIQualifierValue -Class Win32_LogicalDisk -ComputerName computer1 –Property StatusInfo
function Get-WMIQualifierValue
{
param(
[string]$Class=$(Throw “Parameter ‘Class’ cannot be empty”),
[string]$ComputerName=".",
[string]$NameSpace="ROOT\cimv2",
[string]$Property="*"
)
if($PSVersionTable)
{
#PowerShell v2 detected
$wmi = Get-WmiObject meta_class -Filter "__Class = '$class'" -Amended `
-ComputerName $ComputerName -Namespace $NameSpace
}
else
{
#PowerShell v1 detected
$wmi=[wmiclass]"\\$ComputerName\$($NameSpace):$class"
$wmi.psbase.options.useAmendedQualifiers=$true
}
foreach ($p in $wmi.psbase.properties)
{
$names = $p.qualifiers | ForEach-Object {$_.name}
if($names -contains "values" -AND $names -contains "valuemap")
{
$pLen = "-" * $p.name.length
$value = $p.qualifiers["Values"].value
$meaning = $p.qualifiers["ValueMap"].value
$map = $value | Select-Object Value,@{Name="Meaning";Expression={$_}}
1..$map.length | ForEach-Object { $map[$_-1].value=$meaning[$_-1] }
$map = $map | Add-Member NoteProperty Name $p.name –PassThru
if($Property -eq "*")
{
Write-Host ("`n$pLen`n"+$p.name+"`n$pLen")
$map | Select-Object Value,Meaning | Format-Table –AutoSize
}
if($p.name -eq $Property)
{
Write-Host ("`n$pLen`n"+$p.name+"`n$pLen")
$map | Where-Object {$_.name -eq $Property } | Select-Object Value,Meaning | Format-Table –AutoSize
break
}
}
}
}