Which verbs can I use when naming my PowerShell commands?
Posted: (EET/GMT+2)
When you write your own PowerShell functions or modules, it's a good practice to use the approved verbs only, instead of inventing your own. Microsoft publishes a list of these verbs (some are really noins, like "New"). That keeps your commands consistent with the rest of PowerShell and easier to find with tab completion.
In addition to reading the docs, you can also see all approved verbs with:
Get-Verb | Sort-Object Verb
That lists familiar ones like "Get", "Set", "New", "Remove", "Start", and so on. The verbs are also grouped by category, which is nice.
When you define a function, just use one of those verbs:
function Get-ServerStatus {
param([string]$Name)
Test-Connection -ComputerName $Name -Count 1
}
If you use an unapproved verb, PowerShell will show a warning when you import the module. It still works, but it's worth keeping your verbs "official". This helps both others and you (in the future) to quickly understand what your function does.
If you're ever unsure which verb fits best, check the category in the "Get-Verb" list. For example, "Start" for actions, "Get" for retrieving, "Set" for modifying, and "Test" for validations.