PowerTip: Use CIM and PowerShell to Find WMI Classes

Summary: Use CIM and Windows PowerShell to find WMI classes related to threads.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily find WMI classes that are related to threads?

Hey, Scripting Guy! Answer Use the Get-CimClass cmdlet, and specify a wildcard character for threads:

Get-CimClass *thread*

Comments (1)

  1. kelleymd says:

    The above example will only search root/cimv2, or a single specified namespace when using the -namespace parameter. There is no recurse or wildcard available with the namespace parameter, and the get-cimclass does not allow the search item to be passed
    via pipeline. I use where-object (?) to find ALL related classes when I am digging around in WMI. The below example will recurse all namespaces that your account has permissions to view/read.

    gwmi -Namespace root -list -Recurse | ?{$_.Name -match "thread"}

    And, if you want to stack search options, you can. This example is very useful if you want to find all related classes that also have methods that you can call:

    gwmi -Namespace root -list -Recurse | ?{$_.Name -match "reg" -and $_.Methods -ne $null} | select Path,Methods

Skip to main content