如何在 PowerShell 中获取 cmdlet 支持的参数?

powershellmicrosoft technologiessoftware & coding更新于 2026/2/9 21:52:17

要了解 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 属性是支持的参数。


相关文章