当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] Get-Verb (Microsoft.PowerShell.Utility)

作者:精品下载站 日期:2024-12-14 02:06:04 浏览:14 分类:玩电脑

Get-Verb (Microsoft.PowerShell.Utility)


Get-Verb

模块 :Microsoft.PowerShell.Utility

获取批准的 PowerShell 动词。

句法

Get-Verb
   [[-Verb] <String[]>]
   [[-Group] <String[]>]
   [<CommonParameters>]

描述

Get-Verb 函数获取批准在 PowerShell 命令中使用的动词。

建议 PowerShell cmdlet 和函数名称采用动词-名词 格式并包含经过批准的动词。这种做法使命令名称更加一致、可预测且更易于使用。

使用未经批准的动词的命令仍然在 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[]

接受的值:

通用、通信、数据、诊断、生命周期、其他、安全

位置:

1

默认值:

所有组

必需的:

False

接受管道输入:

True

接受通配符:

False

-Verb

仅获取指定的动词。输入动词的名称或名称模式。允许使用通配符。

类型 :

String[]

位置:

0

默认值:

所有动词

必需的:

False

接受管道输入:

True

接受通配符:

True

输入

您无法通过管道将对象传递到此 cmdlet。

输出

动词信息

笔记

PowerShell 动词根据其最常见的用途分配到一个组。这些组的目的是使动词易于查找和比较,而不是限制它们的使用。您可以对任何类型的命令使用任何批准的动词。

每个 PowerShell 动词都分配给以下组之一。

  • 通用:定义可应用于几乎所有 cmdlet 的通用操作,例如添加。
  • 通信:定义适用于通信的操作,例如连接。
  • 数据:定义适用于数据处理的操作,例如备份。
  • 诊断:定义适用于诊断的操作,例如调试。
  • 生命周期:定义适用于 cmdlet 生命周期的操作,例如“完成”。
  • 安全性:定义适用于安全性的操作,例如撤销。
  • 其他:定义其他类型的操作。

一些随 PowerShell 安装的 cmdlet(例如 Tee-ObjectWhere-Object)使用未经批准的动词。这些 cmdlet 是历史上的例外,它们的动词被归类为保留

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯