Im a newbie to powershell, I am trying to remove NUL character in the file. Below is snapshot of file
Original file snaphsot
I tried using below code to remove NUL character in line2
$filepath=<File name>
[STRING]$test = [io.file]::ReadAllText($filepath)
$test = $test -replace "\x00","`n"
$test = $test -replace "`n"," "
echo $test
$test | out-file ./testoutput.txt
but the code made all record into single record.
I also tried below code
$filepath=<filename>
$tempath=<temp file name>
Move-Item -Path $filepath -Destination $temppath
ForEach ($file in (Get-Content $temppath)) {
[STRING]$test = $file
$test = $test -replace "`0",""
$test = $test -replace "`r`n",""
echo $test
$test | out-file $filepath -Append
}
that removed NUL character however second row which made to appear like multiple row
Converted file image
My requirement is to remove NUL character and make second row as single row instead multiple row .appreciate any help on this