Powershell: Convert Hex to Int type

Hi,

short post today. Topic: convert a hex string to an integer type.

This can be done by a simple cast. Consider to use try/catch to handle any exceptions.

$sMyHexValue="0xff"
$iInt=[Int32]$sMyHexValue
write-host "HexString:" $sMyHexValue  "HexFormatedFromInt" ([string]::Format("0x{0:x}",$iInt)) "Int:" $iInt
HexString: 0xff HexFormatedFromInt 0xff Int: 255

Michael

Advertisment to support michlstechblog.info

Time limit is exhausted. Please reload CAPTCHA.

Original Theme by Schiy · Powered by WordPress