Monthly Archive

Categories

PowerShell approved verbs

PowerShell uses a verb-noun style for naming cmdlets. The list of Powershell approved verbs is available at https://docs.microsoft.com/en-us/powershell/developer/cmdlet/approved-verbs-for-windows-powershell-commands.

 

You should use the approved verbs when writing functions or cmdlets. Import-Module will complain about using unapproved verbs.

 

You can also see the list of approved verbs using Get-Verb.

 

There’s also a set of verb naming rules that are meant for you to follow. Some are good ideas like not using the reserved verbs – others such as dictating the use of Pascal syntax I ignore because I prefer to use lower case for function names. It helps me remember which is my code! If I was publishing to the gallery I’d probably conform but as I tend to write proof of concept code more than anything I want to keep a visual separation.

 

The other very useful set information are the synonyms for verbs that you shouldn’t use. For instance don’t use Append, Attach, Concatenate or Insert – use Add. Some of this information is contextual though as you shouldn’t use Pop or Out as a synonym for Exit BUT Pop is perfectly valid when removing an item off a stack (Pop-Location is the only cmdlet I know of that works in that way).

Comments are closed.