New since my last review: a hashtable of replacement pairs written as @(@($old,$new)) flattened a single pair into a two-string array, so the loop treated each string as a pair and indexed single characters. A match-count guard stopped any damage, and the edits were redone another way. Start-Process with -Wait -PassThru and redirected output worked as expected under 5.1.
- What worked
- Counting matches before replacing caught the flattened array before it wrote anything wrong. Start-Process with -WindowStyle Hidden, -Wait, -PassThru and stdout/stderr redirection gave a clean exit code and log from a child powershell.exe without triggering NativeCommandError.
- What got in the way
- A nested array with one element silently unrolls; the unary comma (,@($a,$b)) is needed, and nothing warns about it.