PoshBytes: Get-Verb Before You Get Judged

PowerShell verbs are not just naming suggestions. Get-Verb helps you find approved verbs so your functions are easier to discover and your modules do not yell at people.

This post is a companion for the YouTube short PoshBytes: Get-Verb Before You Get Judged.

One of the first things you notice in PowerShell is that commands follow a Verb-Noun pattern.

Get-Process
Start-Service
Expand-Archive

The idea is simple. The verb says what the command does. The noun says what it does it to. And while nouns are a free for all (mostly), not every verb is “approved”.

If you have ever written a function like this:

function Parse-Stuff {
    'MyStuff'
}

It works.

Parse-Stuff

But PowerShell will judge you for it.

The problem

When you run PSScriptAnalyzer, you may see something, like below, complaining about unapproved verbs.

The cmdlet ‘Parse-Stuff’ uses an unapproved verb.

That is PowerShell politely saying, “I understood what you meant, but may let’s not.”

And if that function is inside a module, importing it can give you this lovely little warning:

Import-Module MyStuff

WARNING: The names of some imported commands from the module ‘stuff’ include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.

Well thankfully PowerShell has a list of approved verbs.

Use Get-Verb

To see what verbs you can use without PowerShell publicly shaming you use the Get-Verb cmdlet.

Get-Verb

Want to find verbs related to data?

Get-Verb -Group Data | Format-Table Verb, Description

Let’s take a close look at a one

Get-Verb -Verb Convert | Format-List Verb, Description

Now instead of Parse-Stuff, maybe we use:

function Convert-Stuff {
    'All that other code'
}

Now, PowerShell is happy, and all is good.

Some verbs are obvious, if you want to get something…use Get

function Get-Stuff {
    'MyStuff'
}

Or creating something new…New

function New-Stuff {
    'My New Stuff'
}

The goal is not just avoiding warnings. Approved verbs make your commands easier for others to find, easier to understand, and less likely to look like they were named after you had three cups of gas station coffee.

Similar verbs matter too

Some verbs sound similar, but they imply different behavior.

For example, Get usually means retrieve something.

Get-Process
Get-Service
Get-Content

You are asking PowerShell to go fetch information.

But Read usually implies consuming or interpreting a stream of data.

Read-Host

That command is actively reading input from you.

And yes, PowerShell cares about this level of detail. Nobody is searching for Read commands when they want to Get something.

Single Nouns

And one more thing. Your nouns should usually be singular. Because PowerShell assumes you are smart enough to understand there might be more than one.

Get-Process
Not Get-Processes

And while plural nouns are not technically forbidden, posting them online is a fantastic way to meet people who own too many mechanical keyboards.

Wrap Up

• Get-Verb lists approved PowerShell verbs.
• PSScriptAnalyzer warns when functions use unapproved verbs.
• Modules can show import warnings for unapproved verbs.
• Approved verbs make commands easier to discover.
• Better names help future you, who is already tired.

Leave a Reply

Your email address will not be published. Required fields are marked *