Use Hash Tables To Convert Numeric Return Values

by Mar 29, 2011

You can use Hash Tables to translate individual return values to clear text. This example shows you how to convert return codes 0 and 5 to some clear text representation:

$cleartext = @{
0 = success
5 = access denied
}

You can use the return value as an index to get back the clear text representation of a numeric return value:

$rv = [some call to a command producing a numeric return value]
$cleartext[$rv]

 

Twitter This Tip!
ReTweet this Tip!