Get-Verb
獲得核准的 PowerShell 動詞。
語法
Default (預設值)
Get-Verb
[[-Verb] <String[]>]
[[-Group] <String[]>]
[<CommonParameters>]
Description
函 Get-Verb 式會獲得經核准用於 PowerShell 指令的動詞。
建議 PowerShell 的 cmdlet 和函式名稱都必須有格式, Verb-Noun 並包含核准的動詞。 這種做法讓指令名稱更一致、更可預測,也更容易使用。
使用未經核準動詞的指令,仍然可以在 PowerShell 中執行。 然而,當你匯入包含帶有未核准動詞的指令的模組時,該 Import-Module 指令會顯示警告訊息。
Note
回 Get-Verb 傳的動詞列表可能不完整。 如需最新核准的 PowerShell 動詞清單及說明,請參見 核准動詞。
範例
範例一 - 取得所有動詞的清單
Get-Verb
範例二 - 取得一份以「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[] |
| 預設值: | All groups |
| 接受的值: | Common, Communications, Data, Diagnostic, Lifecycle, Other, Security |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | 1 |
| 必要: | False |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-Verb
只能讀取指定的動詞。 輸入動詞名稱或名稱模式。 允許使用萬用牌。
參數屬性
| 類型: | String[] |
| 預設值: | All verbs |
| 支援萬用字元: | True |
| 不要顯示: | False |
參數集
(All)
| Position: | 0 |
| 必要: | False |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
CommonParameters
此 cmdlet 支援常見參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸入
None
您不能將物件透過管道傳送到此 Cmdlet。
輸出
VerbInfo
備註
PowerShell 動詞會根據其最常用的用途分配到群組。 這些群組的設計目的是讓動詞容易被找到和比較,而非限制它們的使用。 你可以用任何核准的動詞來執行任何類型的指令。
每個 PowerShell 動詞會被分配到以下其中一個群組。
- 常見:定義可適用於幾乎任何 cmdlet(例如 Add)的通用動作。
- 通訊:定義適用於溝通的行動,例如連結。
- 資料:定義適用於資料處理的動作,例如備份。
- 診斷:定義適用於診斷的動作,例如除錯。
- 生命週期:定義適用於指令長程式生命週期的動作,例如 Complete。
- 安全性:定義適用於安全性的行動,例如撤銷(Revoke)。
- 其他:定義其他類型的行動。
部分隨 PowerShell 安裝的指令檔,如 Tee-Object 和 Where-Object,使用未經核發的動詞。 這些指令長為歷史例外,其動詞被歸類為 保留動詞。