Search WMI for Useful Information

by Nov 20, 2015

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
    }
}

Search-WMI -Keyword network

Twitter This Tip! ReTweet this Tip!