Exploring WMI with PowerShell

by Mar 27, 2020

The Win32_LogicalDevice WMI class represents all logic devices available in a computer, and by querying this “superclass”, you get back all the specialized individual classes. This is a simple way of finding out what kind of information WMI can get you, and what the names of WMI classes are:

Get-CimInstance -ClassName CIM_LogicalDevice | 
    Select-Object -Property Name, CreationClassName, DeviceID, SystemName | 
    Out-GridView -Title 'Select one or more (hold CTRL)' -PassThru 

In the grid view window, select one or more instances you find interesting (hold CTRL to select multiple), and the selected instances are dumped to your console. Wait for the grid view window to be completely filled before you try and select something.

On my notebook I found a “Audio device” which I selected:

Name                   CreationClassName DeviceID                              
----                   ----------------- --------                              
Intel(R) Display-Audio Win32_SoundDevice INTELAUDIO\FUNC_01&VEN_8086&DEV_280... 

To find out more information about it, query specific information by using the WMI class found in “CreationClassName”, i.e. Win32_SoundDevice, run this:

PS> Get-CimInstance -ClassName Win32_SoundDevice

Manufacturer         Name                          Status StatusInfo
------------         ----                          ------ ----------
Intel(R) Corporation Intel(R) Display-Audio        OK              3
DisplayLink          DisplayLink USB Audio Adapter OK              3
Realtek              Realtek Audio                 OK              3

Apparently, there were three sound devices available in my machine. To see all details, send the data to Select-Object:

PS> Get-CimInstance -ClassName Win32_SoundDevice | Select-Object *

ConfigManagerUserConfig     : False
Name                        : Intel(R) Display-Audio
Status                      : OK
StatusInfo                  : 3
Caption                     : Intel(R) Display-Audio
Description                 : Intel(R) Display-Audio
InstallDate                 : 
Availability                : 
ConfigManagerErrorCode      : 0
CreationClassName           : Win32_SoundDevice
DeviceID                    : INTELAUDIO\FUNC_01&VEN_8086&DEV_280F&SUBSYS_80860
ErrorCleared                : 
ErrorDescription            : 
LastErrorCode               : 
PNPDeviceID                 : INTELAUDIO\FUNC_01&VEN_8086&DEV_280F&SUBSYS_80860
PowerManagementCapabilities : 
PowerManagementSupported    : False
SystemCreationClassName     : Win32_ComputerSystem
SystemName                  : DESKTOP-8DVNI43
DMABufferSize               : 
Manufacturer                : Intel(R) Corporation
MPU401Address               : 
ProductName                 : Intel(R) Display-Audio
PSComputerName              : 
CimClass                    : root/cimv2:Win32_SoundDevice
CimInstanceProperties       : {Caption, Description, InstallDate, Name...}
CimSystemProperties         : Microsoft.Management.Infrastructure.CimSystemProp

ConfigManagerUserConfig     : False
Name                        : DisplayLink USB Audio Adapter
Status                      : OK
StatusInfo                  : 3
Caption                     : DisplayLink USB Audio Adapter

And if you'd like to learn more about this class (or another one), visit the PowerShell WMI reference: http://powershell.one/wmi/root/cimv2/win32_sounddevice. Simply replace the WMI class name with the one you are after.

PowerShell Conference Europe (psconf.eu) opens June 2, 2020, in Hannover, Germany, and you can be part of it! 4 days, 3 tracks, 80 PowerShell sessions, and 40 renown speakers from around the world (including PowerShell inventor Jeffrey Snover, the PowerShell team with Steve Lee, the Amazon AWS team, and many more) are waiting for questions and discussions, providing authoritative firsthand information, tips and guidance for professional PowerShell scripters.

Find out more at http://powershell.one/psconfeu/psconf.eu-2020/about, download the mobile app with sessions and speakers at http://psconfeu.sessionize.com/, and secure your seat at https://psconf.eu/register.html.

Twitter This Tip! ReTweet this Tip!