次の方法で共有


Get-Verb

承認済みの PowerShell 動詞を取得します。

構文

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

説明

関数は Get-Verb 、PowerShell コマンドでの使用が承認された動詞を取得します。

PowerShell コマンドレットと関数名の形式は、承認済みの動詞を 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 で導入されました。

Type:String[]
Accepted values:Common, Communications, Data, Diagnostic, Lifecycle, Other, Security
Position:1
Default value:All groups
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Verb

指定した動詞のみを取得します。 動詞の名前または名前パターンを入力します。 ワイルドカードを指定できます。

Type:String[]
Position:0
Default value:All verbs
Required:False
Accept pipeline input:True
Accept wildcard characters:True

入力

None

オブジェクトをこのコマンドレットにパイプすることはできません。

出力

VerbInfo

メモ

PowerShell 動詞は、最も一般的な用途に基づいてグループに割り当てられます。 グループは動詞の検索と比較を簡単にするように設計されています。使用を制限するためではありません。 あらゆる種類のコマンドにあらゆる承認された動詞を使用できます。

各 PowerShell 動詞は、次のいずれかのグループに割り当てられます。

  • 共通: Add など、ほぼすべてのコマンドレットに適用できる汎用アクションを定義します。
  • 通信: Connect などの通信に適用されるアクションを定義します。
  • データ: バックアップなどのデータ処理に適用されるアクションを定義します。
  • 診断: デバッグなど、診断に適用されるアクションを定義します。
  • ライフサイクル: コマンドレットのライフサイクルに適用されるアクション (Complete など) を定義します。
  • セキュリティ: セキュリティに適用されるアクション (取り消しなど) を定義します。
  • その他: 他の種類のアクションを定義します。

PowerShell にインストールされているコマンドレットの中には、 や などTee-ObjectWhere-Object、未承認の動詞を使用するものもあります。 これらのコマンドレットは歴史的な例外であり、その動詞は 予約済みとして分類されます。