I'm using StringBuilder.Replace in a PowerShell script to strip out line breaks in text fields before outputting to a log file. Below is an example of what I'm using... and it works perfectly on our development environment. However, on the live environment, no line breaks are stripped out at all. Does anyone know what could be causing it to differ from environment to environment? There is a lot more content on the live server, but since the actual system is identical to the dev, all the text fields themselves are the same.
$log = "C:\mylogfile.csv"
$newline = [System.Environment]::NewLine
$sb2 = New-Object System.Text.StringBuilder
$sb2.Append("Text fields")
$sb2.Replace($newline,".")
$sb2.ToString() | Out-File $log -Append