What To Do / Not to Do in PowerShell: Part 10

Whenever you're writing a script, function, or even an advanced function, you should give those things a cmdlet-style name, consisting of a Verb-SingularNoun. You get to make up your SingularNoun, but the Verb should come fromthis list at Microsoft (scroll down to see the 7 Verbs catagories, and click on one to see its verbs).

Why?

Consistency. As an admin, I know what a Get cmdlet does. I know what to expect from Invoke, Write, Out, Format, Export, Set, New, and so forth. Throw me some weird verb like "instantiate" and I'll have no clue what to expect. I won't be able to discover that cmdlet on my own, either, because it doesn't have one of the standard verbs.

Consistency in cmdlet names (as well as parameter names) is a key to helping people use your command more easily and effectively. 

What's more, you shoudl get in the habit of appending some company-level prefix to your nouns. Work for Boeing? Maybe your cmdlet names should look like "Get-BngUser" so that there's less chance of them ever conflicting with someone else's cmdlet names. Oh, and never use the "PS" prefix - that's reserved for the PowerShell team at Microsoft.

Discuss this Blog Entry 1

on Jul 25, 2011
Awesome series with some great tips that I need to start paying attention to. My only concern is that each tip doesn't have a direct link to the next tip in the series. The "Related Content" section doesn't always, either. Makes following the tips from the beginning a little difficult.

Please or Register to post comments.

What's PowerShell with a Purpose Blog?

Don Jones demystifies Windows PowerShell.

Blog Archive

Sponsored Introduction Continue on to (or wait seconds) ×