假設您有一個返回某些內容的方法或cmdlet,但是您不想使用它,也不想輸出它。我發現了兩種方法:Add-Item > $null[void]Add-ItemAdd-Item | Out-Null你用什么?哪種方法更好/更清潔?為什么?
3 回答

蝴蝶刀刀
TA貢獻1801條經驗 獲得超8個贊
還有Out-Nullcmdlet,您可以在管道中使用該cmdlet,例如Add-Item | Out-Null。
無效手冊頁
NAME
Out-Null
SYNOPSIS
Deletes output instead of sending it to the console.
SYNTAX
Out-Null [-inputObject <psobject>] [<CommonParameters>]
DETAILED DESCRIPTION
The Out-Null cmdlet sends output to NULL, in effect, deleting it.
RELATED LINKS
Out-Printer
Out-Host
Out-File
Out-String
Out-Default
REMARKS
For more information, type: "get-help Out-Null -detailed".
For technical information, type: "get-help Out-Null -full".
- 3 回答
- 0 關注
- 1161 瀏覽
添加回答
舉報
0/150
提交
取消