PowerShell script to convert decimal number to hexadecimal value

Here is a little PS script to convert a decimal number to hexadecimal value.

I use an inputbox function to get the input (It’s a string), convert it to Integer and then use the .NET formatting method to convert the integer to its hexadeicmal counterpart.

$a = new-object -comobject MSScriptControl.ScriptControl
$a.language = "vbscript"
$a.addcode("function getInput() getInput = inputbox(`"Enter The Decimal Number`",`"Convert Decimal Number to Hexadecimal Value`") end function" )
$b = $a.eval("getInput")
$c = [int] $b
$c = "{0:X}" -f $c
Write-host "The Hexadecimal value is: " $c


Written by , Posted .

Leave a Comment

You must be logged in to post a comment.