June 28, 2011 7:07 pm
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.
[ComponentModel.Win32Exception]5
How about error code 32…
[ComponentModel.Win32Exception]32
One more, I have this error in my windowsupdate.log that I don’t feel like looking up online:
[ComponentModel.Win32Exception]0x800700de
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.
Posted by Boe Prox
Categories: scripts
Mobile Site | Full Site
Get a free blog at WordPress.com Theme: WordPress Mobile Edition by Alex King.
Very useful. Thanks !
By freakbynature on November 14, 2017 at 1:36 am
Now if only .Net errors would have error codes…
By Nyerguds on July 14, 2017 at 12:04 pm
This is great! Thanks!
By Dan Rusu on May 25, 2017 at 6:38 am
[…] Boe Prox shows us how to translate Windows error codes with PowerShell […]
By Episode 152 – PrimalForms 2011 with Alex and David « PowerScripting Podcast on July 7, 2011 at 10:19 pm
Nice article, bro — I like it a lot.
By Trevor Sullivan on June 28, 2011 at 8:16 pm
Thanks Trevor! I appreciate the comment!
By Boe Prox on June 28, 2011 at 8:18 pm