Automating the world one-liner at a time…
In PowerShell v1, we published a set of cmdlet design guidelines that included direction on how to properly name cmdlets. Throughout the v2 cycle, we've seen an increase in cmdlet authors deviating from the standards in unexpected ways. Our user community (you all) has become particularly vocal in recent months that we needed to do something in v2 to curb this trend.
This led to a series of discussions on our team about an appropriate course of action for v2. The outcome of those discussions includes changes to Import-Module where we will perform name checking on imported commands. We decided not to disallow unapproved verbs or characters (i.e. the import succeeds), but we will display a warning on import of commands that use unapproved verbs or characters as a user-visible speed bump to more strongly encourage the right behavior.
If you think you might be using unapproved verbs or characters in your commands, please see the Additional Details section below.
As described in the summary above, we've taken some action recently to address the issue of cmdlet authors departing from the design guidelines, which appears to be increasing in frequency and severity lately. We've had many in-depth discussions on the PowerShell team over the past several weeks about how to address this problem and what might be feasible in v2 given our schedule for Windows 7. We believe we have some improved guidance and mitigation that will help curb departures from the guidelines, bubble up the need to adhere to the prescribed naming format, and provide a clear path from v1 to v2 and beyond.
First, it's helpful to look at what we've done in v2 as the basis for determining what the guidance should look like, both for those implementing on v1 only as well as those targeting v2 or looking to move eventually to v2. In v2, we're using modules as the primary mechanism to address the issues of namespaces, code isolation, and naming collisions, so this is where we've targeted some changes. With modules, we've provided a few options as described in the following guidelines:
Microsoft.WSMan.Management\Connect-WSManMicrosoft.PowerShell.Core\Get-History
In v2, you can also use the module name as the qualifier. For example:
BitsTransfer\Add-BitsFileServerManager\Get-WindowsFeature
With v1, we took the approach of exposing the rules above strictly as design guidelines with no enforcement mechanism or other restrictions in the PowerShell engine itself. However, we're concerned that with rapidly accelerating adoption in v2, we're going to see a proliferation of people deviating from the guidelines, whether through lack of knowledge of the guidelines or a different view about what the guidelines should be or refusal to adhere to the guidelines for one reason or another. We've spent a considerable amount of time debating what level checking to do and how violations should get exposed to the user. With the introduction of modules in v2, we have a one-time opportunity to perform at least some level of verification on imported commands against the guidelines.
Here's a detailed description of the name validation behavior we're adding to Import-Module:
Some imported command names include unapproved verbs which might make them less discoverable. Use the Verbose parameter for more detail or type Get-Verb to see the list of approved verbs.
Some imported command names contain one or more of the following restricted characters: # , ( ) { } [ ] & - / \ $ ^ ; : " ' < > | ? @ ` * % + = ~
The command name '<command>' contains one or more of the following restricted characters: # , ( ) { } [ ] & - / \ $ ^ ; : " ' < > | ? @ ` * % + = ~
The command name '<command>' includes an unapproved verb which might make it less discoverable. The suggested alternative verbs are "<approved verb>", "<approved verb>", "<approved verb>".
We realize that some products might already have shipped with commands that don't adhere to the guidelines. Our recommendation is that as these products move forward in future releases, the command names should be changed to adhere to the guidelines. To avoid breaking customer scripts written using the old commands, we recommend creating aliases for the old commands that map to the new names. Since we don't perform name checking on aliases, no warnings will be displayed for these aliases as long as the underlying function/cmdlet has been changed to use approved naming conventions.
Dan HarmanProgram ManagerWindows PowerShell
PingBack from http://asp-net-hosting.simplynetdev.com/increasing-visibility-of-cmdlet-design-guidelines/
Your list prohibited characters includes '-' .. does this mean I can not export Module functions with Verb-Noun syntax?
It would be easier to take these recommendations seriously if groups within Microsoft followed them.
@Carter
Absolutely. That was one of the key arguments for having CODE instead of merely documentation to back up the standards.
Jeffrey Snover [MSFT]
Distinguished Engineer
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
@Confused,
My interpretation here is that you cannot use a 2nd hyphen anywhere in your funtion name.
So this will work:
My-Function
But this won't:
My-Custom-Function
With the recent changes in v2 to increase the visibility of the cmdlet design guidelines , we want to
This is a most sensible idea. I agree with Carter that the PowerShell team needs to start inside Microsoft, but Jeffrey's reply makes sense.
I think there might be some mileage in classifying nouns too, but with less importance. Could there be an official set of nouns that customers could add to (say stored in nouns.xml in $PSHOME??).
Also, there should be a GPO value to disable the strict name checking (or to always turn it on explicitly). Just because my firm develops a "bad" set of cmdlets, there's not much point in constantly warning me (ie the user) as I can't do anything about it. Displaying an error message that I can't do anything about seems poor practice.