I’m creating some runbooks with Powershell scripts to collect info on sites and databases, and writing them out to the Task Log. Unfortunately when I put any lines inside a code segment such as a foreach, the output all appears on one line no matter if I use Write-Host, Write-Output, or just a variable. Newlines are just ignored. Is there any way to get newlines to appear so I don’t have to go through the extra steps of formatting the info and emailing it?
For instance:
Write-Host “one line”
Foreach ($app in $apps) {
Write-Host $app.name
}
Would output:
oneline
app1 app2 app3
And that’s even if I put multiple Write-Host commands inside the foreach loop.