WMI Search Tool

by Oct 15, 2014

All PowerShell Versions

WMI is a great and powerful technique: simply specify a WMI class name, and back you get all the instances of that class:

PS> Get-WmiObject -Class Win32_BIOS


SMBIOSBIOSVersion : 76CN27WW
Manufacturer      : LENOVO
Name              : 76CN27WW
SerialNumber      : 1006250300406
Version           : LENOVO - 1
     

How do you know the WMI classes, though? Here is a search tool:

function Find-WMIClass
{
   param
   (
      [Parameter(Mandatory=$true)]
      $SearchTerm = 'Resolution'
   )
   
   Get-WmiObject -Class * -List | 
   Where-Object { $_.Properties.Count -ge 3 } |
   Where-Object { $_.Name -notlike 'Win32_Perf*'  } |
   Where-Object {
      $ListOfNames = $_.Properties | Select-Object -ExpandProperty Name
      ($ListOfNames -like "*$SearchTerm*") -ne $null
   } |
   Sort-Object -Property Name  
} 

Simply specify a search term you are after. The code will find all WMI classes that contain a property with the search term in its name (use wildcards to widen the search).

This will find all relevant WMI classes that have a property that ends with “resolution”:

PS> Find-WMIClass -SearchTerm *resolution


   NameSpace: ROOT\cimv2

Name                                Methods              Properties               
----                                -------              ----------               
CIM_CacheMemory                     {SetPowerState, R... {Access, AdditionalErr...
CIM_CurrentSensor                   {SetPowerState, R... {Accuracy, Availabilit...
CIM_FlatPanel                       {SetPowerState, R... {Availability, Caption...
CIM_Memory                          {SetPowerState, R... {Access, AdditionalErr...
CIM_MonitorResolution               {}                   {Caption, Description,...
CIM_NonVolatileStorage              {SetPowerState, R... {Access, AdditionalErr...
CIM_NumericSensor                   {SetPowerState, R... {Accuracy, Availabilit...
CIM_PCVideoController               {SetPowerState, R... {AcceleratorCapabiliti...
CIM_PointingDevice                  {SetPowerState, R... {Availability, Caption...
CIM_Printer                         {SetPowerState, R... {Availability, Availab...
CIM_Tachometer                      {SetPowerState, R... {Accuracy, Availabilit...
CIM_TemperatureSensor               {SetPowerState, R... {Accuracy, Availabilit...
CIM_VideoController                 {SetPowerState, R... {AcceleratorCapabiliti...
CIM_VideoControllerResolution       {}                   {Caption, Description,...
CIM_VolatileStorage                 {SetPowerState, R... {Access, AdditionalErr...
CIM_VoltageSensor                   {SetPowerState, R... {Accuracy, Availabilit...
Win32_CacheMemory                   {SetPowerState, R... {Access, AdditionalErr...
Win32_CurrentProbe                  {SetPowerState, R... {Accuracy, Availabilit...
Win32_DisplayControllerConfigura... {}                   {BitsPerPixel, Caption...
Win32_MemoryArray                   {SetPowerState, R... {Access, AdditionalErr...
Win32_MemoryDevice                  {SetPowerState, R... {Access, AdditionalErr...
Win32_NetworkAdapterConfiguration   {EnableDHCP, Rene... {ArpAlwaysSourceRoute,...
Win32_PointingDevice                {SetPowerState, R... {Availability, Caption...
Win32_Printer                       {SetPowerState, R... {Attributes, Availabil...
Win32_PrinterConfiguration          {}                   {BitsPerPel, Caption, ...
Win32_SMBIOSMemory                  {SetPowerState, R... {Access, AdditionalErr...
Win32_TemperatureProbe              {SetPowerState, R... {Accuracy, Availabilit...
Win32_VideoConfiguration            {}                   {ActualColorResolution...
Win32_VideoController               {SetPowerState, R... {AcceleratorCapabiliti...
Win32_VoltageProbe                  {SetPowerState, R... {Accuracy, Availabilit... 

Next, pick a class name and look at the actual data:

PS> Get-WmiObject -Class CIM_CacheMemory | Select-Object -Property * 

Twitter This Tip! ReTweet this Tip!