Quick Hits: Translate Windows Error Codes

Sometimes while working in Windows you might see some logs or receive an error message that are just numbers. Something like a 5 or maybe a 32. Regardless, these are nothing short of confusing and make you have to Google (or Bing) to find out what exactly that number means. Or maybe you have a crazy curiosity to see what numbers translate to a windows error… Either way, there is a .NET namespace that can answer all of those questions. That namespace is ComponentModel.Win32Exception.

Lets look at the error code 5.



How about error code 32…



One more, I have this error in my windowsupdate.log that I don’t feel like looking up online:



Pretty cool, isn’t it?

Ok, so this isn’t groundbreaking, but it is just another cool thing that you can do with PowerShell.

For even more fun, you can run this to find all sorts of error codes:

1..1000 | % {"$($_): $((([ComponentModel.Win32Exception]$_) -split ": ")[1])"} | more


This shows error codes 614-662 and would continue on to 1000.

Feel free to take it beyond 1000 and see what other error codes there are to see.

This entry was posted in scripts and tagged , , . Bookmark the permalink.

6 Responses to Quick Hits: Translate Windows Error Codes

  1. freakbynature says:

    Very useful. Thanks !

  2. Nyerguds says:

    Now if only .Net errors would have error codes…

  3. Dan Rusu says:

    This is great! Thanks!

  4. Pingback: Episode 152 – PrimalForms 2011 with Alex and David « PowerScripting Podcast

  5. Trevor Sullivan says:

    Nice article, bro — I like it a lot.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s