Wednesday, 1 January 2014

Write-Host Considered Harmful

I read an interesting article written by Jeffrey Snover on the topic of Write-Host vs Write-Output. The article can be seen here.

In a nutshell:
The correct cmdlet to use is Write-Output. Using Write-Output will display the results to the screen when you run you script by itself but, it will also allow your script to be used in a pipeline (or foreach loop) and have the results used by other scripts/cmdlets.

See also


Why I Use Write-Host In PowerShell
This article gives some of the benefits of using Write-Host cmdlet.



Keywords: powershell write-host write-output

No comments:

Post a Comment