Looking Up Cryptic Error Codes

by Nov 21, 2014

All PowerShell versions

Often, WMI and API calls return cryptic numeric error codes. To find out what went wrong, try this little helper function:

function Get-HelpForErrorCode([String]$Code)
{
  if ($Code.StartsWith('-'))
  {
    $Code = '{0:X8}' -f ([Int32]$Code)
  }
  $url = "http://www.computerperformance.co.uk/Logon/code/code_$Code.htm"
  Start-Process -FilePath $url
} 

You can submit any decimal or hexadecimal error code, and the function opens the appropriate web page where the error is explained (if information is available):

 
PS> Get-HelpForErrorCode -2146828235
 

The website will display information similar to this:

Twitter This Tip! ReTweet this Tip!