Getting Help for WMI Objects

by May 4, 2020

WMI is extremely powerful but a little underdocumented. To change this, a group has formed and is creating a PowerShell-specific WMI reference: https://powershell.one/wmi

To easily look up help, you can add the Help() method to all of your WMI and CIM instance objects. Simply run this code:

$codeCim = {
 $url = 'https://powershell.one/wmi/{0}/{1}' -f $this.CimSystemProperties.Namespace.Replace("/","\"),
  # add class
  $this.CimSystemProperties.ClassName

  Start-Process -FilePath $url.ToLower()
}
$codeWmi = {
 $url = 'https://powershell.one/wmi/{0}/{1}' -f $this.__Namespace, $this.__Class

  Start-Process -FilePath $url.ToLower()
}

Update-TypeData -TypeName Microsoft.Management.Infrastructure.CimInstance -MemberType ScriptMethod -MemberName Help -Value $codeCim -Force
Update-TypeData -TypeName System.Management.ManagementObject -MemberType ScriptMethod -MemberName Help -Value $codeWmi -Force

When you now retrieve information from Get-WmiObject or Get-CimInstance, each object has the new Help() method that automatically opens the appropriate reference page in your browser:

 
PS> $result = Get-WmiObject -Class Win32_Share

PS> $result[0].Help() 

PS> $result.Help()



PS> $result = Get-CimInstance -ClassName Win32_StartupCommand

PS> $result.Help()
 

If you want to participate and have useful WMI example code, please go to the appropriate reference page and add your code via the comment functionality at the bottom.


Twitter This Tip! ReTweet this Tip!