Share via


Get-Verb

取得已核准的PowerShell動詞。

Syntax

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

Description

Get-Verb 式會取得已核准用於PowerShell命令的動詞。

建議 PowerShell Cmdlet 和函式名稱具有 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

輸出

VerbInfo

備註

PowerShell 動詞會根據其最常見用途指派給群組。 這些群組的設計可讓您輕鬆地尋找並比較動詞命令,而不限制其用途。 您可以為任何類型的命令使用任何已核准的動詞命令。

每個 PowerShell 動詞都會指派給下列其中一個群組。

  • 常見:定義幾乎可以套用至任何 Cmdlet 的泛型動作,例如 Add。
  • 通訊:定義適用於通訊的動作,例如 Connect。
  • 數據:定義適用於數據處理的動作,例如備份。
  • 診斷:定義套用至診斷的動作,例如偵錯。
  • 生命週期:定義套用至 Cmdlet 生命周期的動作,例如 Complete。
  • 安全性:定義套用至安全性的動作,例如 Revoke。
  • 其他:定義其他類型的動作。

一些隨 PowerShell 一起安裝的 Cmdlet,例如 Tee-ObjectWhere-Object,會使用未經核准的動詞。 這些 Cmdlet 是歷史例外狀況,其動詞會分類為 保留