Jana Sattainathan has some thoughts on when to use each of the Write- cmdlets in Powershell:
PowerShell has matured as the automation tool of choice on the Microsoft platform, be it on Windows or Azure. However, there is no official guidance on best-practices and standards around some things. At times, bloggers do things incorrectly in their examples thereby reinforcing bad practices. Hopefully, this small post will help connect some dots for you! Please comment if I am stating something that is not a generally accepted best practice. Specifically, we are going to glance at the following cmdlets
-
Write-Host
-
Write-Output
-
Write-Debug
-
Write-Warning
-
Write-Error/Throw
-
Write-Verbose
-
Write-Progress
Write-Host is the easiest and probably most controversial of the set (because its messages are outside the pipeline), but there’s a place for each of these.