PowerShell: Convert UTF-8 file to ASCII stripping NULs

I have a file which is UTF-8 encoded and has a NUL between each character. The file was created using the SSIS log file output.

Using PowerShell we can get the content, remove the NUL, output in a readable file format.

$c = (Get-Content $Path -Encoding UTF8) 

$c -replace "`0", ""  |Out-File -LiteralPath $OutFile -Encoding ASCII

explorer $OutFile

Comments are closed.

Post Navigation