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 動詞動詞的更新清單,請參閱 已核准的動詞。

範例

範例 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

您無法使用管線將物件傳送至此 Cmdlet。

輸出

VerbInfo

備註

PowerShell 動詞命令會根據其最常見用途指派給群組。 這些群組的設計目的是讓動詞更容易尋找和比較,而不是限制其使用。 您可以針對任何類型的命令使用任何已核准的動詞。

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

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

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