Get-Verb
获取已批准的 PowerShell 谓词。
语法
Get-Verb
[[-Verb] <String[]>]
[[-Group] <String[]>]
[<CommonParameters>]
说明
Get-Verb
函数获取批准在 PowerShell 命令中使用的谓词。
建议 PowerShell cmdlet 和函数名称具有 Verb-Noun
格式,并包含已批准的谓词。 这种做法使命令名称更加一致、可预测且更易于使用。
使用未经批准的谓词的命令仍在 PowerShell 中运行。 但是,当你导入包含名称中带有未经批准的谓词的命令的模块时,Import-Module
命令会显示一条警告消息。
注意
Get-Verb
返回的谓词列表可能不完整。 有关带说明的已批准 PowerShell 谓词的更新列表,请参阅 已批准的谓词。
示例
示例 1 - 获取所有谓词的列表
Get-Verb
示例 2 - 获取以“un”开头的已批准谓词列表
Get-Verb un*
Verb AliasPrefix Group Description
---- ----------- ----- -----------
Undo un Common Sets a resource to its previous state
Unlock uk Common Releases a resource that was locked
Unpublish ub Data Makes a resource unavailable to others
Uninstall us Lifecycle Removes a resource from an indicated location
Unregister ur Lifecycle Removes the entry for a resource from a repository
Unblock ul Security Removes restrictions to a resource
Unprotect up Security Removes safeguards from a resource that were added to prevent it from attack or loss
示例 3 - 获取安全组中的所有已批准谓词
Get-Verb -Group Security
Verb AliasPrefix Group Description
---- ----------- ----- -----------
Block bl Security Restricts access to a resource
Grant gr Security Allows access to a resource
Protect pt Security Safeguards a resource from attack or loss
Revoke rk Security Specifies an action that does not allow access to a resource
Unblock ul Security Removes restrictions to a resource
Unprotect up Security Removes safeguards from a resource that were added to prevent it from attack or loss
示例 4 - 查找模块中具有未批准的谓词的所有命令
Get-Command -Module Microsoft.PowerShell.Utility | Where-Object Verb -NotIn (Get-Verb).Verb
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Sort-Object 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Tee-Object 3.1.0.0 Microsoft.PowerShell.Utility
参数
-Group
仅获取指定的组。 输入组的名称。 不允许通配符。
此参数是在 PowerShell 6.0 中引入的。
类型: | String[] |
接受的值: | Common, Communications, Data, Diagnostic, Lifecycle, Other, Security |
Position: | 1 |
默认值: | All groups |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-Verb
仅获取指定的谓词。 输入谓词或名称模式的名称。 允许通配符。
类型: | String[] |
Position: | 0 |
默认值: | All verbs |
必需: | False |
接受管道输入: | True |
接受通配符: | True |
输入
None
不能通过管道将对象传递给此 cmdlet。
输出
备注
PowerShell 谓词根据最常用的用途分配给组。 这些组旨在使谓词易于查找和比较,而不是限制其使用。 可以对任何类型的命令使用任何批准的谓词。
每个 PowerShell 谓词都分配给以下组之一。
- 常见:定义可应用于几乎所有 cmdlet 的泛型作,例如 Add。
- 通信:定义适用于通信的作,例如 Connect。
- 数据:定义应用于数据处理的作,例如备份。
- 诊断:定义适用于诊断的作,例如调试。
- 生命周期:定义应用于 cmdlet 生命周期的作,例如 Complete。
- 安全性:定义应用于安全性的作,例如 Revoke。
- 其他:定义其他类型的作。
一些随 PowerShell 一起安装的 cmdlet(如 Tee-Object
和 Where-Object
)使用未经批准的谓词。 这些 cmdlet 是历史性的例外,其谓词被归类为保留 。