WMI is a powerful information repository – if you know the names of WMI classes:

Get-CimInstance -ClassName Win32_BIOS
Get-CimInstance -ClassName Win32_Share
Get-CimInstance -ClassName Win32_OperatingSystem

If you want to explore WMI, then the following code may come handy. Find-WmiClass accepts a simple keyword such as “video”, “network”, “ipaddress”. It then retrieves all WMI classes that contain the keyword either in its class name, or one of its properties or methods.

function Find-WmiClass
    Write-Progress -Activity "Finding WMI Classes" -Status "Searching"
    # find all WMI classes...
    Get-WmiObject -Class * -List | 
    # that contain the search keyword
    Where-Object {
        # is there a property or method with the keyword?
        $containsMember = ((@($_.Properties.Name) -like "*$Keyword*").Count -gt 0) -or ((@($_.Methods.Name) -like "*$Keyword*").Count -gt 0)
        # is the keyword in the class name, and is it an interesting type of class?
        $containsClassName = $_.Name -like "*$Keyword*" -and $_.Properties.Count -gt 2 -and $_.Name -notlike 'Win32_Perf*'
        $containsMember -or $containsClassName
    Write-Progress -Activity "Find WMI Classes" -Completed
$classes = Find-WmiClass 
$classes | 
    # let the user select one of the found classes
    Out-GridView -Title "Select WMI Class" -OutputMode Single |
    ForEach-Object {
        # get all instances of the selected class
        Get-CimInstance -Class $_.Name | 
            # show all properties
            Select-Object -Property * |
            Out-GridView -Title "Instances"

The user can then select one of the classes found, and the code then shows the actual instances of this class.

Disclaimer: there are some rare classes with thousands of instances, such as CIM_File. When selecting a WMI class with so many instances, the script may take a long time to complete.

Are you an experienced professional PowerShell user? Then learning from default course work isn’t your thing. Consider learning the tricks of the trade from one another! Meet the most creative and sophisticated fellow PowerShellers, along with Microsoft PowerShell team members and PowerShell inventor Jeffrey Snover. Attend this years’ PowerShell Conference EU, taking place April 17-20 in Hanover, Germany, for the leading edge. 35 international top speakers, 80 sessions, and security workshops are waiting for you, including two exciting evening events. The conference is limited to 300 delegates. More details at www.psconf.eu.

Twitter This Tip! ReTweet this Tip!