# (separated from) Find And Replace 2-Byte Binary File

**URL:** <https://forums.powershell.org/t/separated-from-find-and-replace-2-byte-binary-file/20499>\
**Category:** PowerShell Help\
**Created:** [September 22, 2022, 7:15am UTC](https://forums.powershell.org/t/separated-from-find-and-replace-2-byte-binary-file/20499 "2022-09-22T07:15:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrlabmate](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/mrlabmate/32/3960_2.png) [@mrlabmate](https://forums.powershell.org/u/mrlabmate)\
**Post date:** [September 22, 2022, 7:15am UTC](https://forums.powershell.org/t/separated-from-find-and-replace-2-byte-binary-file/20499/1 "2022-09-22T07:15:03Z")

</div>

Can you please, share your script, I am unable use [matt-bloomfield] instruction

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [September 22, 2022, 7:32am UTC](https://forums.powershell.org/t/separated-from-find-and-replace-2-byte-binary-file/20499/2 "2022-09-22T07:32:57Z")

</div>

Mrlabmate,  
Welcome to the forum. 👋🏽

I separated your post from the old thread.

> [@Find And Replace 2-Byte Binary File](https://forums.powershell.org/t/find-and-replace-2-byte-binary-file/15308/6):
>
> Something like this should work. I tested it on a text file so it’s easy to see the result but it should work the same for binary files. The text file just contained the word ‘hello’, and the code replaces the first two letters. #Read in the text file as bytes $bytes = Get-Content E:\Temp\filea.txt -Encoding Byte -ReadCount 0 #Convert the bytes to hex $hexString = [System.BitConverter]::ToString($bytes) #Replace 'h' and 'e' with 'f' and 'g' $newHexString = $hexString -replace '68-65','66-67…

> [@mrlabmate](#):
>
> I am unable use [matt-bloomfield] instruction

What does that mean?

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:16pm UTC](https://forums.powershell.org/t/separated-from-find-and-replace-2-byte-binary-file/20499/3 "2024-05-16T20:16:34Z")

</div>

Closed on May 16, 2024, 8:16pm UTC


