about

links

scripts

Sharing linux/windows scripts and tips

Write-Information > Write-Host

September 06, 2018 — Jesse Harris

June Blender writing for Hey, Scripting Guy! Blog:

Hey, Scripting Guy! Blog

The dilemma was how to fix the harmful aspects of Write-Host (can't suppress, capture, or redirect), but keep it from polluting the output stream. And of course, the solution must be backward compatible.
This most elegant solution is provided by the information stream and the Write-Information cmdlet. The information stream is a new output stream that works much like the error and warning streams.

The information stream is a feature of powershell versions 5.x that I missed when it came out. Thus I have been avoiding using Write-Host in favour of Write-Verbose since reading about Write-Host Considered Harmful.

Write-Host Considered Harmful

If you care about writing reusable automation friendly code, go have a read.

Tags:

powershell

streams

© Jesse Harris

mailto:jesse@zigford.org

Generated with bashblog, a single bash script to easily create blogs like this one

bashblog