I'm using Start-Transcript and Stop-Transcript in PowerShell v2.0 to provide basic logging to my collection of scripts. I noticed that each line of text produced by Write-Host and Write-Verbose (the other write cmdlets might be equally affected but I didn't check) have only a LineFeed ("`n") at the end rather than CarriageReturnLineFeed ("`r`n") as expected. This can be easily reproduced by running the following commands:
Start-Transcript Test.log
Write-Verbose "Hello, World!" -verbose
Write-Host "Goodbye, World..."
Stop-Transcript
I first noticed this because notepad doesn't handle the bare LineFeed correctly and all my logging appeared on a single line. I used notepad++ to show all characters and quickly noticed the cause. You can artificially inject the CarriageReturns manually:
Start-Transcript Test.log
Write-Verbose "Hello, World!`r" -verbose
Write-Host "Goodbye, World...`r"
Stop-Transcript
I'd rather not add "`r" to each and all logging lines if I can avoid it. Is there any way to mitigate this without adding "`r" at the end of each logging line?