I'm trying to write a script to search the contents of a file, and when it comes across a grouping of ASCII control characters, to insert a CR/LF.
The pattern of characters I would like to replace are [ETX][NUL][STX][ETX][SOH]
$filenames = @(Get-Childitem "E:\VendorFiles\*") $CR = @("[char]3 [char]0 [char]2 [char]3 [char]1") foreach ($file in $filenames) {$outfile = "$file" + ".txt" Get-Content $file | Foreach-object { $_ -replace $CR,"`r`n" ` -replace [char]3,"|" ` -replace [char]1,"{" ` -replace "\\","\\" ` } | Set-Content -encoding "UTF8" $outfile}