PowerShell: Write-Host or Write-Output?

Use Write-Output. (Almost all the time.)

(You can probably stop reading now if you like.)

Generally, use Write-Host if you want to make the text a funny colour etc – but that’s not always supported anyway.

If you want to read more and learn about various edge cases etc, cool. Lot’s of people have written much longer blog posts on the topic:

(But we both know you only came here for the first line of this blog post.)

Finally, it’s probably responsible to acknowledge that this blog post is deliberately a bit over simplistic. If you would like to read an articulate counter argument, you should check out:

Happy coding!

  1 comment for “PowerShell: Write-Host or Write-Output?

Leave a Reply

Your email address will not be published.