Am trying to perform binary hex edit from the command line using only powershell. Have had partial success performing a hex replace with this snip. Problem springs up when
You already have a byte array, so you could simply modify the bytes at any given offset.
$bytes = [System.IO.File]::ReadAllBytes("C:\OldFile.exe") $offset = 23 $bytes[$offset] = 0xFF $bytes[$offset+1] = 0xFF $bytes[$offset+2] = 0xFF [System.IO.File]::WriteAllBytes("C:\NewFile.exe", $bytes)