One of the unsung features of PowerShell are the many ways to provide output. For completely automated script via Scheduled Task or Orchestrator, I go straight to the Event Log now.
But for the majority of scripts you’ll run on the command line, there is a lot more than Write-Output. By the way, Don Jones says God kills a puppy each time you use Write-Host, so don’t do that.
Excellent for trace level information and you can enable/disable with –Debug and $DebugPreference.
· Step by step information like “Now running trash compactor…”, switched with –Verbose and $VerbosePreference.
Show of hands, who actually knew this was there? Now you do. Switched with –WarningAction and $WarningPreference.
Looks just like a regular paragraph long red error message, switched with –ErrorAction and $ErrorPreference.
I’m moving all inline comments to Write actions and making decisions about the right level of notice along the way. I definitely like the ability to control output when running scripts now.