Scripting Games 2012 Tip: Proper Function Names

Many of you will compete in the Scripting Games this year, and most of you will look to write an Advanced Function or two or more. When doing this, one thing to keep in mind is the naming of the function.

The proper naming of a PowerShell function is to use a Verb-Singular Noun naming convention. To add to that, there is a list of ‘approved verbs’ that you should look at using to stay consistent with naming standards.

To see the list of approved verbs, run the following command:

Get-Verb | Format-Wide -Column 3

image

If you want to know more about what each Verb is used for, just use Get-Verb and it will give you the Group that it belongs to.

As long as you use an approved verb and a singular noun like this…

Get-Server
Set-LogFile
Select-LogFile
Add-Right

…you should be ok. But if you choose to use something that doesn’t fit this criteria, expect people to comment about it and advise you to change it something that is approved.

Obviously, your nouns that you use will vary based on the objective. Make sure that the function name you choose makes sense and fits the idea of what the function itself is trying to accomplish.

About Boe Prox

Microsoft Cloud and Datacenter MVP working as a SQL DBA.
This entry was posted in Scripting Games 2012 and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s