# read the binary data as byte array [byte[]]$data = [System.IO.File]::ReadAllBytes('D:\Test\blah.exe') # write to new file as string of hex encoded characters [System.IO.File]::WriteAllText('D:\Test\blah.hex',[System.BitConverter]::ToString($data).Replace('-',''), [System.Text.Encoding]::ASCII)