在PowerShell中忽略输出的更好(更简洁)的方法是什么?

假设您有一个返回某些内容的方法或cmdlet,但是您不想使用它,也不想输出它。我发现了两种方法:


Add-Item > $null


[void]Add-Item


Add-Item | Out-Null

你用什么?哪种方法更好/更清洁?为什么?


慕码人8056858
浏览 762回答 3
3回答

大话西游666

还有Out-Nullcmdlet,您可以在管道中使用该cmdlet,例如Add-Item | Out-Null。无效手册页NAME&nbsp; &nbsp; Out-NullSYNOPSIS&nbsp; &nbsp; Deletes output instead of sending it to the console.SYNTAX&nbsp; &nbsp; Out-Null [-inputObject <psobject>] [<CommonParameters>]DETAILED DESCRIPTION&nbsp; &nbsp; The Out-Null cmdlet sends output to NULL, in effect, deleting it.RELATED LINKS&nbsp; &nbsp; Out-Printer&nbsp; &nbsp; Out-Host&nbsp; &nbsp; Out-File&nbsp; &nbsp; Out-String&nbsp; &nbsp; Out-DefaultREMARKS&nbsp; &nbsp; &nbsp;For more information, type: "get-help Out-Null -detailed".&nbsp; &nbsp; &nbsp;For technical information, type: "get-help Out-Null -full".
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Photoshop