Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create vs. New - Powershell approved verbs

Tags:

powershell

I'm trying to abide as strictly as possible to Microsoft's Powershell development guidelines and best practices but I am getting warnings on importing a custom module:

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'.

I couldn't find information anywhere else but maybe someone here can tell me why is it that the word New should be used over the word Create?

In my case, the function 'Create-iRule' does just that, it creates an iRule.

I know someone is bound to post an answer stating: "But you are creating a 'New-iRule' so that should be the name of the function!" To those people, I'll remind you that New isn't a verb, whereas Create is.

So why is New on the list of approved verbs and Create outputs a warning?

Approved Verbs for Windows PowerShell Commands

like image 927
ShaneC Avatar asked Oct 21 '14 11:10

ShaneC


People also ask

What are approved and unapproved verbs for PowerShell cmdlets?

All cmdlets must used approved verbs. Approved verbs can be found by running the command Get-Verb. Additional documentation on approved verbs can be found in the microsoft docs page Approved Verbs for PowerShell Commands . Some unapproved verbs are documented on the approved verbs page and point to approved alternatives.

How do I use PowerShell verbs?

Use one of the predefined verb names provided by PowerShell Use the verb to describe the general scope of the action, and use parameters to further refine the action of the cmdlet. Do not use a synonym of an approved verb. For example, always use Remove, never use Deleteor Eliminate. Use only the form of each verb that is listed in this topic.

Where can I find the approved and unapproved verbs?

Approved verbs can be found by running the command Get-Verb. Additional documentation on approved verbs can be found in the microsoft docs page Approved Verbs for PowerShell Commands . Some unapproved verbs are documented on the approved verbs page and point to approved alternatives.

What is the use of read invoke and start in PowerShell?

Use the Read verb to open a resource and either extract information contained within. Use the Invoke verb to perform synchronous operations, such as running a command and waiting for it to end. Use the Start verb to begin asynchronous operations, such as starting an autonomous process. Use the Test verb.


1 Answers

According to Microsoft:

PowerShell uses the term verb to describe a word that implies an action even if that word is not a standard verb in the English language. For example, the term New is a valid PowerShell verb name because it implies an action even though it is not a verb in the English language.

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

like image 112
s31064 Avatar answered Oct 01 '22 15:10

s31064