Press "Enter" to skip to content

Don’t Use Write-Host

Steve Jones warns us away from Write-Host in Powershell:

I’ve written a few scripts and programs lately, mostly just for fun. In those scripts, I’ve used Write-Host to return output. To me, it’s been like “Print” in various languages where I can get output of a program. Often I’ll use a method/function to get info and then use print to output that to the caller.

However a few people noted that in my last script, Write-host wasn’t necessary. When I asked why, both Mike Fal and Drew Furgiule responded.

Mike and Drew are smart cookies.  Write-Host has some major limitations which hinder developers’ abilities to modularize and package viable code.