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.
Very useful. Thanks !
Now if only .Net errors would have error codes…
This is great! Thanks!
Pingback: Episode 152 – PrimalForms 2011 with Alex and David « PowerScripting Podcast
Nice article, bro — I like it a lot.
Thanks Trevor! I appreciate the comment!