Out-Null cmdlet 旨在用于立即放弃接收的任何输入。 这对放弃收到的不利于运行命令的不必要数据很有用。 键入下面的命令时,该命令不会返回任何内容:

Get-Command | Out-Null

Out-Null cmdlet 不会放弃错误输出。 例如,如果输入下面的命令,则将显示一条消息,通知你 Windows PowerShell 无法识别“Is-NotACommand”:

PS C:\Users\maxsu> Get-Command | Out-Null
PS C:\Users\maxsu> Get-Command Is-NotACommand | Out-Null
Get-Command : 无法将“Is-NotACommand”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径
,请确保路径正确,然后再试一次。
所在位置 行:1 字符: 1
+ Get-Command Is-NotACommand | Out-Null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Is-NotACommand:String) [Get-Command], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand