Discarding Streams

by Jul 13, 2020

PowerShell outputs information via different streams. Warnings are written to a different stream than output, and errors again go to a different stream. Each stream has a unique numeric identifier:

ID Stream
1 Output
2 Error
3 Warning
4 Verbose
5 Debug
6 Information

If you want to silence a stream, you can use the redirection operator (“>”) and redirect the stream(s) to $null. This line would discard any error or warning messages:

 
Get-Process -FileVersionInfo 2>$null 3>$null  
 


Twitter This Tip! ReTweet this Tip!