Category Archives: WMI

Search WMI for Useful Information in  PowerShell

Search WMI for Useful Information

Source: Search WMI for Useful Information – Power Tips – PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources

<#

WMI is a great source of information, but it is not always easy to find out the names of valid WMI classes to query.

Here is a little search tool: it asks for a keyword, then searches WMI for all valid classes with this keyword. The results are shown in a grid view window, and when you choose a class and press OK, the tool queries the class for you, showing the results:

#requires -Version 3

#>

function Search-WMI
{
param([Parameter(Mandatory=$true)]$Keyword)

Get-WmiObject -Class “Win32_*$Keyword*” -List |
Where-Object { $_.Properties.Count -gt 6 } |
Where-Object { $_.Name -notlike ‘Win32_Perf*’ } |
Sort-Object -Property Name |
Select-Object -Property @{Name=’Select one of these classes’; Expression={$_.Name }} |
Out-GridView -Title ‘Choose one’ -OutputMode Single |
ForEach-Object {
Get-WmiObject -Class $_.’Select one of these classes’ | Out-GridView
}
}

<#

Example:

Search-WMI -Keyword network

#>