I have a powershell script, and I want to write to the console and write to the log file with one call.
I did it...
Start-Transcript -Path $TargetDir\Log.log
Write-Host "Stuff"
... which works great, except that the new lines it creates are LF, which means that my logs look great in every text editor on earth except notepad.
Here is what I have for this ...
function global:Write-Notepad
(
[string] $Message,
[string] $ForegroundColor = 'Gray'
)
{
Write-Host "$Message`r" -ForegroundColor $ForegroundColor
}
... which writes a CR to the end of each message, but it doesn't seem to write lines like this ...
&$ACommand | Write-Notepad
I'm not sure what syntax the pipeline operator expects, but I would really appreciate the help.
source
share