Powershell Core 6.2 Cookbook
上QQ阅读APP看书,第一时间看更新

How it works...

When a cmdlet is executed, PowerShell automatically uses the different streams to convey information. It's mostly up to the developer to make use of those streams. With a scripted cmdlet, this means using the Write cmdlets. By using the common parameters, the availability of a stream can be controlled.

Apart from controlling the availability of a stream, the entire stream can also be stored in a variable before allowing it to continue through the pipeline.

The reason why we try not to use Write-Host when developing a script is that the Write-Host cmdlet won't write to any of the streams. Instead, the console host is used to display text. The problem with this behavior is that the user has no control over the visibility of the host messages.