PowerShell 技能连载 - 丢弃数据流
PowerShell 通过不同的流输出信息。警告写入到与输出不同的流中,而错误也写入不同的流。每个流都有一个唯一的数字标识符:
| ID | Stream |
| 1 | Output |
| 2 | Error |
| 3 | Warning |
| 4 | Verbose |
| 5 | Debug |
| 6 | Information |
如果要丢弃某个流,可以使用重定向运算符(“>”)并将流重定向到 $null。此行代码将丢弃任何错误或警告消息:
1 | Get-Process -FileVersionInfo 2>$null 3>$null |
PowerShell 技能连载 - 丢弃数据流

