Get-WmiHelp & Search-WmiHelp

PowerShell Team

Both PowerShell and Windows Management Instrumentation (WMI) are pretty incredible technologies that can do a lot of amazing things, but we’re all human, and keeping an encyclopedic mental reference of all of these amazing things would give Good Will Hunting a headache.  For years, when I used WMI I almost always had a browser open to MSDN to help me figure out and remember the little details of a class in WMI, and, for all of the desktop clutter, it never bothered me… until I started using Powershell and had Get-Help and Get-Command.

These two cmdlets rocked my world.  Get-Command could tell me all of the commands in a system, and the properties they accepted.  Get-Help told me what the cmdlet did, and how to use it.  All of a sudden I had the kinds of information I was always looking up online right at my fingertips… but not for WMI.

Luckily, it turns out that WMI actually has a way to provide help information.  If you run Get-WmiObject, you can see what I mean:

 Get-WmiObject __Namespace | Format-Table Name

This lists the namespaces underneath root\cimv2.  You should have at least one namespace named something like ms_### .  This namespace contains localized class help for the WMI classes in the parent namespace.

This means that no matter where in the world you are, you can get help from WMI in your language without connecting to the internet.

I wrote a few functions to make this feature of WMI a lot easier to access. 

Get-WmiHelp: Gets you a dictionary with the help for a specific WMI class
Search-WmiHelp: Searches through the namespace for classes that match certain filters

Here are some examples:

Get-WmiHelp Win32_Process

Name                           Value
—-                               —–
Description                    The Win32_Process class represents a sequence…
Properties                     {QuotaPeakPagedPoolUsage, CSCreationClassName…
Methods                       {Terminate, AttachDebugger, Create, GetOwner…}

(Get-WmiHelp Win32_Bios).Description

The Win32_BIOS class represents the attributes of the computer system’s basic input/output services (BIOS) that are installed on the computer.

(Get-WmiHelp Win32_Process).Methods.Create

The Create method creates a new process.
The method returns an integer value that can be interpretted as follows:
0 – Successful completion.
2 – The user does not have access to the requested information.
3 – The user does not have sufficient privilge.
8 – Unknown failure.
9 – The path specified does not exist.
21 – The specified parameter is invalid.
Other – For integer values other than those listed above, refer to Win32 error code documentation.

(Get-WmiHelp Win32_Volume).Properties.StatusInfo

StatusInfo is a string indicating whether the logical device is in an enabled (value = 3), disabled (value = 4) or some other (1) or unknown (2) state. If thi
s property does not apply to the logical device, the value, 5 (“Not Applicable”), should be used. 

Search-WmiHelp {$_ -like “*Disk*”} # Finds all classes whose description contains “Disk”

Name                                          Value
—-                                               —–
Win32_OperatingSystemAutoch… {Description, Properties, Methods}
Win32_Volume                             {Description, Properties, Methods}

Search-WmiHelp -Method {$_.Key -like “*Create*} # Finds all classes that contain a method named create

Name                              Value
—-                                   —–
Win32_Service                 {Description, Properties, Methods}
Win32_BaseService          {Description, Properties, Methods}
Win32_TerminalService     {Description, Properties, Methods}
Win32_Share                   {Description, Properties, Methods}

Search-WmiHelp -Property {$_.Value -like “*Quota*} # Finds all classes that contain a property whose description contains “Quota”

Name                                  Value
—-                                       —–
Win32_QuotaSetting             {Description, Properties, Methods}
Win32_LogicalDisk               {Description, Properties, Methods}
Win32_VolumeQuota            {Description, Properties, Methods}
Win32_VolumeUserQuota     {Description, Properties, Methods}
Win32_Process                   {Description, Properties, Methods}
Win32_MappedLogicalDisk   {Description, Properties, Methods}
Win32_Volume                    {Description, Properties, Methods}
Win32_VolumeQuotaSetting {Description, Properties, Methods}
Win32_DiskQuota                {Description, Properties, Methods} 

 Hope this helps,

 James Brundage [MSFT]

Update: I have added a -Culture option to Get-WmiHelp and Search-WmiHelp.  If Search-WmiHelp is giving you an “Invalid Namespace” error, then run:

 Get-WmiObject “__Namespace” | Format-List Name and try passing the value of any ms_### namespace to Get-WmiHelp/Search-WmiHelp

 e.g. Get-WmiHelp Win32_Process -culture 0xc0a:

Name                           Value
—-                           —–
Description                    La clase Win32_Process representa una secuenc…
Properties                     {QuotaPeakPagedPoolUsage, CSCreationClassName…
Methods                        {Terminate, AttachDebugger, Create, GetOwner…} 



Discussion is closed.

Feedback usabilla icon