创建与新建 - Powershell 批准的动词

Sha*_*neC 5 powershell

我试图尽可能严格地遵守 Microsoft 的 Powershell 开发指南和最佳实践,但在导入自定义模块时收到警告:

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'.
Run Code Online (Sandbox Code Playgroud)

我在其他任何地方都找不到信息,但也许这里有人可以告诉我为什么应该在 Create 一词上使用 New 一词?

就我而言,“Create-iRule”函数就是这样做的,它创建了一个 iRule。

我知道有人肯定会发布一个回答说:“但是你正在创建一个' New-iRule ',所以它应该是函数的名称!” 对于这些人,我会提醒您New 不是动词,而 Create 是.

那么为什么 New 在批准的动词列表中并 Create 输出警告?

经批准的 Windows PowerShell 命令动词

小智 5

根据微软的说法:

PowerShell 使用术语“动词”来描述暗示某个操作的单词,即使该单词不是英语中的标准动词。例如,术语“New”是有效的 PowerShell 动词名称,因为它暗示一个操作,即使它不是英语中的动词。

https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands


aph*_*ria 2

我没有明确的来源,所以这是推测,但是NewandAdd是首先存在的有效动词,并且似乎(我认为)涵盖了您可能使用 的任何情况Create

我知道,当他们添加新动词时,他们会尽量避免与现有动词重叠。

来自Windows PowerShell 博客的征求新动词帖子:

为了提供一些背景信息,以下是我们在决定是否添加新动词时考虑的事项:

  • 与现有批准的动词很少或没有重叠
  • 广泛适用于多种技术 - 必须与领域无关
  • 在多个上下文中以相似的含义一致使用
  • 与相反的配对很好,但不是必需的