Convert Format-Hex PowerShell table to raw hex dump

Question:

I used the Format-Hex command in PowerShell to get the hex contents of a string. My command "some_string" | format-hex gives me the output in a table. How can I make it into a raw hex dump so it’s something like 736f6d655f737472696e67?

Answer:

Expand the Bytes property of the resulting object, format each byte as a double-digit hex number, then join them:


However, it’d probably be simpler and more straightforward to write a custom function to converts a string to a hex representation:

Source:

Convert Format-Hex PowerShell table to raw hex dump by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply