Auto-Discovering Online Help for WMI

by Jan 28, 2013

Get-WmiObject is a great and simple cmdlet to retrieve WMI information, and the parameter -List returns all available WMI class names that you can specify:

# search for WMI class name:
PS> Get-WmiObject -Class *Share* -List

# retrieve all instances of WMI class:
Get-WmiObject -Class Win32_Share

To really dive into WMI, you will want to get full documentation for all the WMI classes. While documentation is available in the Internet, the URLs for those websites are cryptic.

Here is a clever way how you can translate WMI class names into the cryptic URLs: use PowerShell 3.0 Invoke-WebRequest to search for the WMI class using a major search engine, and then retrieve the URL:

function Get-WmiHelpLocation
{
  param ($WmiClassName='Win32_BIOS')

  $uri = 'http://www.bing.com/search?q={0}+site:msdn.microsoft.com' -f $WmiClassName

  $url = (Invoke-WebRequest -Uri $uri -UseBasicParsing).Links |
  Where-Object href -like 'http://msdn.microsoft.com*' |
  Select-Object -ExpandProperty href -First 1
  $url
  Start-Process $url
} 

When you run Get-WmiHelpLocation, it returns the URL for the WMI class specified and also opens the web page in your default browser:

PS> Get-WmiHelpLocation Win32_Share
http://msdn.microsoft.com/en-us/library/aa394435(VS.85).aspx 

Note: If your Internet access requires a proxy server or authentication, add the appropriate parameters to Invoke-WebRequest inside the function Get-WmiHelpLocation.

Twitter This Tip! ReTweet this Tip!