In a PowerShell script I'm exporting data read from a SQL Server query into a .csv file tab delimited. I need to remove any carriage return characters.
-replace '`r`n'
isn't working. I think the character is char(13)
.
Here's my code line that doesn't work:
(Get-Content $MyCSV_DOR) | % {$_ -replace '`r`n', " "} | out-file -FilePath $MyCSV_DOR -Force -Encoding ascii
I've also tried the below:
`r, `n, \r, \n and \r\n
All of them fail to remove the character. I've also looked at the suggested other posts.
Are there any suggestions?