Convert decimal to hex and binary in Powershell

dec to hex

PS> "{0:x}" -f 397312
61000
PS> [String]::Format("{0:x}", 397312)
61000
PS> [Convert]::ToString(397312, 16)
61000

If you want the hex number to have 6 digits then use

PS> "{0:x6}" -f 397312
061000

hex to dec

PS> "{0:d}" -f 0x61000
397312

PS> [String]::Format("{0:d}", 0x61000)
397312

PS> [Convert]::ToString(0x061000, 10)
397312

dec to bin

PS> [Convert]::ToString(129, 2)
10000001

hex to bin

PS> [Convert]::ToString(0x81, 2)
10000001
Advertisements

Tagged:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

smsagent

Scripts, tools and tips, mostly around Microsoft SCCM and EMS

To The Point

Anything about Technology and Business

Brian's Power Windows Blog

Microsoft in the Enterprise. Windows, Hyper-V, Exchange, SQL, and more!

PowerScripting Podcast

Shownotes and links for the PowerScripting Podcast, a podcast to help people learn Windows Powershell

Learn Powershell | Achieve More

What is this Powershell of which you speak?

%d bloggers like this: