这只是我为参加我的自动化课程/会议/活动的人们提供的“掌握 PowerShell 帮助”文件的一部分。也许它会帮助你。
# Get specifics for a module, cmdlet, or function
(Get-Command -Name Set-ADUser).Parameters
(Get-Command -Name Set-ADUser).Parameters.Keys
Get-help -Name Set-ADUser -Examples
Get-help -Name Set-ADUser -Full
Get-help -Name Set-ADUser -Online
# Find all cmdlets / functions with a target parameter
Get-Command -CommandType Cmdlet |
Where-Object {
Try {$PSItem.parameters.keys -match 'credential'}
Catch{}
}|
Out-GridView -PassThru -Title '
Available cmdlets which have a specific parameter'
Get-Command -CommandType Function |
Where-Object {
Try {$PSItem.parameters.keys -match 'credential'}
Catch{}
}|
Out-GridView -PassThru -Title '
Available functions which have a specific parameter'
# Get property enums/options for a specifc cmdlet/function
(Get-Service | Select-Object -First 1).Status.GetType()
[System.ServiceProcess.ServiceControllerStatus]::
GetNames([System.ServiceProcess.ServiceControllerStatus])
为什么要这样做……
Get-Command Set-ADUser -Syntax
...与这个...
(Get-Command -Name Set-ADUser).Parameters.Keys |
Out-GridView -PassThru -Title 'Select an item to view its properties and methods'|
Get-Member -Force |
Out-GridView
(OGV 允许实时过滤。)
..或者只是这样做
Show-Command -Name Set-ADUser
如果您在 ISE 中,只需使用“命令”选项卡并双击感兴趣的命令,而不是使用原始文本。
如果您在 VSCode 中,请选择命令资源管理器并双击感兴趣的命令,然后单击帮助图标,而不是使用原始文本。
然而,如果你只是想留在控制台主机并使用文本,那么这个...
<#
List of all parameters that a given cmdlet supports along with a short
description:
#>
Get-Help Set-ADUser -para '*' |
Format-Table Name, { $PSItem.Description[0].Text } -wrap
Get-Help Set-ADUser -para '*' |
Where-Object -Property Name -Match 'Office' |
Format-Table Name, { $PSItem.Description[0].Text } -wrap
使用 OGV 进行实时过滤和选择,但在控制台文本中获取结果。
Get-Help Set-ADUser -para '*' |
Where-Object -Property Name -Match ((Get-Command -Name Set-ADUser).Parameters.Keys |
Out-GridView -PassThru -Title 'Select an item to view its syntax details') |
Format-Table Name, { $PSItem.Description[0].Text } -wrap
更新
根据您的评论...
如何为参数的变量类型添加另一列?
看看办公室的例子,我怎么能添加一个列
包含
...你可以这样做。
Get-Help Set-ADUser -Parameter '*' |
Where-Object -Property Name -Match ((Get-Command -Name Set-ADUser).Parameters.Keys |
Out-GridView -PassThru -Title 'Select an item to view its syntax details') |
ForEach {
[PSCustomObject]@{
Name = $PSItem.Name
Type = $PSItem.Type.Name
Description = $PSItem.Description[0].Text
}
} |
Format-Table Name, Type, Description -wrap
# Results
<#
Name Type Description
---- ---- -----------
Office String Specifies the location of the user's office or place of business. This parameter sets the Office property of a user object. The LDAP
display name (ldapDisplayName) of this property is "office".
OfficePhone String Specifies the user's office telephone number. This parameter sets the OfficePhone property of a user object. The LDAP display name
(ldapDisplayName) of this property is "telephoneNumber".
#>