Thursday, October 21, 2010

Display System Error Description in Powershell

In a powershell script, I need to see description system errors and constant value

I find the solution on Ward Horsfall site
http://wiki.slothx.net/index.php?title=Powershell.


# Decode a Win32 Error Code. Example below x5A8.

$err_msg = (new-object System.ComponentModel.Win32Exception(0x5A8));
$err_msg;
Scroll bar range cannot be greater than MAXLONG



For information, you can find list of System Error Codes at
http://msdn.microsoft.com/en-us/library/ms681381(v=VS.85).aspx
and
here some informations about FormatMessage

No comments: