Get-Verb
承認済みの PowerShell 動詞を取得します。
構文
Get-Verb
[[-Verb] <String[]>]
[[-Group] <String[]>]
[<CommonParameters>]
説明
関数は Get-Verb
、PowerShell コマンドでの使用が承認された動詞を取得します。
PowerShell コマンドレットと関数名の形式は Verb-Noun
、承認済みの動詞を含めるのが推奨されます。 この方法により、コマンド名の一貫性が高く、予測可能になり、使いやすくなりました。
未承認の動詞を使用するコマンドは、引き続き PowerShell で実行されます。 ただし、未承認の動詞を名前に含むコマンドを含むモジュールをインポートすると、警告メッセージが Import-Module
表示されます。
注意
を返す動詞リストが Get-Verb
完全でない可能性があります。 説明を含む承認済み PowerShell 動詞の更新された一覧については、Microsoft Docsの承認済み動詞に関するページを参照してください。
例
例 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[] |
Position: | 0 |
Default value: | All verbs |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Verb
指定した動詞のみを取得します。 動詞の名前または名前パターンを入力します。 ワイルドカードを指定できます。
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: | True |
入力
None
出力
メモ
PowerShell 動詞は、最も一般的な用途に基づいてグループに割り当てられます。 グループは動詞の検索と比較を簡単にするように設計されています。使用を制限するためではありません。 あらゆる種類のコマンドにあらゆる承認された動詞を使用できます。
各 PowerShell 動詞は、次のいずれかのグループに割り当てられます。
- 共通: Add など、ほぼすべてのコマンドレットに適用できる汎用アクションを定義します。
- 通信: Connect などの通信に適用されるアクションを定義します。
- データ: バックアップなどのデータ処理に適用されるアクションを定義します。
- 診断: デバッグなど、診断に適用されるアクションを定義します。
- ライフサイクル: コマンドレットのライフサイクルに適用されるアクション (Complete など) を定義します。
- セキュリティ: 取り消しなど、セキュリティに適用されるアクションを定義します。
- その他: 他の種類のアクションを定義します。
や などTee-Object
Where-Object
、PowerShell と共にインストールされるコマンドレットの一部では、未承認の動詞が使用されます。 これらのコマンドレットは歴史的な例外であり、動詞は 予約済みとして分類されます。