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