如何在 PowerShell 中獲得 cmdlet 支援的引數?


要了解哪些引數受 cmdlet 支援,Get-Command 會檢索命令的屬性。例如,我們需要找到 Get-Process 引數,Get-Command 會檢索該命令資訊,完整列表會給你提供該屬性。

Get-Command Get-Process | fl

一旦執行命令,就會顯示 ParameterSets 屬性,這些屬性是 cmdlet 支援的引數。

PS C:\> (Get-Command Get-Process).ParameterSets |ft -AutoSize

Name                    IsDefault Parameters
----                    --------- ----------
Name                         True {Name, ComputerName, Module, FileVersionInfo..}
NameWithUserName            False {Name, IncludeUserName, Verbose, Debug...}
IdWithUserName              False {Id, IncludeUserName, Verbose, Debug...}
Id                          False {Id, ComputerName, Module, FileVersionInfo...}
InputObjectWithUserName     False {InputObject, IncludeUserName, Verbose, Debug…}
InputObject                 False {InputObject, ComputerName, Module, FileVersionInfo...}

上述 Name 屬性是受支援的引數。

更新於: 11-11-2020

228 次瀏覽

開啟你的 職業生涯

完成課程認證

開始
廣告
© . All rights reserved.