我试图尽可能严格遵守Microsoft的Power
shell开发指南和最佳实践,但我收到有关导入自定义模块的警告:
WARNING: The names of some imported commands from the module 'F5Helper' 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.
VERBOSE: The 'Create-iRule' command in the F5Helper' module was imported, but because its name does not include an approved verb, it might be difficult to find.
The suggested alternative verbs are "New".
VERBOSE: Importing function 'Create-iRule'.
我无法在其他任何地方找到信息,但也许有人在这里可以告诉我为什么New这个词应该用在Create这个词上?
在我的例子中,函数’Create-iRule’就是这样,它创建了一个iRule.
我知道有人必须发布一个回答说:“但你正在创建一个’New-iRule’,因此应该是该函数的名称!”
对于那些人,我会提醒你,New不是动词,而Create是.
那么为什么New在已批准的动词和Create输出列表中会出现警告?
Approved Verbs for Windows PowerShell Commands
最佳答案 我没有明确的来源,所以这是猜测,但New和Add是首先存在的有效动词,并且似乎(我认为)涵盖了你可能使用Create的任何情况.
我知道当他们添加新动词时,他们会尽量避免与现有动词重叠.
从Windows PowerShell Blog的Soliciting New Verbs帖子:
To provide some context, here are the things we think about when
deciding whether to add a new verb:
- Little or no overlap with existing approved verbs
- Broadly applicable to multiple technologies – must be domain agnostic
- Used consistently with similar meaning across multiple contexts
- Pairing with an opposite is good, but not required