PowerShell v3 in a Year Day 11 Get Verb

Topic: Get-Verb
Alias: None.


A key design element of the PowerShell system built in to create an intuitive feel for the language is the Verb-Noun pattern used with cmdlet naming. For folks new to this concept, cmdlet names always consist of two parts: 1) a verb and 2) a noun. The verb indicates what you can do with the cmdlet and the noun represents what type of object you can use. In this case, Get-Verb is more of a helper cmdlet, designed to provide a quick, on-the-box reference for approved verb name. By using a standardized set of verbs PowerShell "makes command names more consistent and predictable, and easier to use, especially for users who do not speak English as a first language."

The help then goes on to note, "Commands that use unapproved verbs run in Windows PowerShell. However, when you import a module that includes a command with an unapproved verb in its name, the Import-Module command displays a warning message." To demonstrate what sort of error message you may encounter, I created a simple function with a non-approved verb and saved it as part of module.
function Unapproved-VerbName
{
    Write-Output"I will generate a warning.";
}

Export-ModuleMember -Function *
Next, I saved these commands into a module (.psm1 file) named Unapproved-Verb within a folder of the same name under the modules directory: C:WindowsSystem32WindowsPowerShellv1.0Modules. After adding the file to my module store I ran this command and ran into the error mentioned above:
PS >Import-Module Unapproved-Verb
WARNING: Thenames ofsome importedcommands fromthe moduleUnapproved-Verb includeunapproved verbsthat mightmake them less discoverable.To findthe commandswith unapprovedverbs,run theImport-Module commandagain withthe Verbose parameter.For alist ofapproved verbs, type Get-Verb. 
As you can see, PowerShell will permit the use of unapproved verbs. It just makes sure you understand they are not within the approved list. Honestly, there are few occasion where I really feel a compelling need to go off the reservation, so to speak, but, unapproved verbs will not pose problems other than to prompt a nag screen at the start of your session.

If you need to zero in on a specific verb by a portion of the name, you can use wildcards with the first few letters of the name. In fact, -Verb is the only parameter you can use, aside from the common parameters, to specify what verb you want to learn about. It is worth noting that the verbs, as they are laid out by default, are grouped in alphabetical order by functionality. The current groups are: common, data, lifecycle, diagnostic, communications, security, other. If you cant find what you need in all those, by all means, use another verb. Just realize, youll get a nag screen every time you run the cmdlet unless you pipe it to a select name cmdlet. Also, you can pipe to a where cmdlet to narrow it down by category.

The basic groups, by count, are:

  1. common: 34
  2. data: 24
  3. lifecycle: 20
  4. diagnostic: 7
  5. communications: 6
  6. security: 6
  7. other: 1
And, for the sake of completeness, here is the composite list, extracted with the following command: Get-Verb | ft -AutoSize | clip.
  • Verb        Group         
  • ----        -----         
  • Add         Common        
  • Clear       Common        
  • Close       Common        
  • Copy        Common        
  • Enter       Common        
  • Exit        Common        
  • Find        Common        
  • Format      Common        
  • Get         Common        
  • Hide        Common        
  • Join        Common        
  • Lock        Common        
  • Move        Common        
  • New         Common        
  • Open        Common        
  • Optimize    Common        
  • Pop         Common        
  • Push        Common        
  • Redo        Common        
  • Remove      Common        
  • Rename      Common        
  • Reset       Common        
  • Resize      Common        
  • Search      Common        
  • Select      Common        
  • Set         Common        
  • Show        Common        
  • Skip        Common        
  • Split       Common        
  • Step        Common        
  • Switch      Common        
  • Undo        Common        
  • Unlock      Common        
  • Watch       Common        
  • Backup      Data          
  • Checkpoint  Data          
  • Compare     Data          
  • Compress    Data          
  • Convert     Data          
  • ConvertFrom Data          
  • ConvertTo   Data          
  • Dismount    Data          
  • Edit        Data          
  • Expand      Data          
  • Export      Data          
  • Group       Data          
  • Import      Data          
  • Initialize  Data          
  • Limit       Data          
  • Merge       Data          
  • Mount       Data          
  • Out         Data          
  • Publish     Data          
  • Restore     Data          
  • Save        Data          
  • Sync        Data          
  • Unpublish   Data          
  • Update      Data          
  • Approve     Lifecycle     
  • Assert      Lifecycle     
  • Complete    Lifecycle     
  • Confirm     Lifecycle     
  • Deny        Lifecycle     
  • Disable     Lifecycle     
  • Enable      Lifecycle     
  • Install     Lifecycle     
  • Invoke      Lifecycle     
  • Register    Lifecycle     
  • Request     Lifecycle     
  • Restart     Lifecycle     
  • Resume      Lifecycle     
  • Start       Lifecycle     
  • Stop        Lifecycle     
  • Submit      Lifecycle     
  • Suspend     Lifecycle     
  • Uninstall   Lifecycle     
  • Unregister  Lifecycle     
  • Wait        Lifecycle     
  • Debug       Diagnostic    
  • Measure     Diagnostic    
  • Ping        Diagnostic    
  • Repair      Diagnostic    
  • Resolve     Diagnostic    
  • Test        Diagnostic    
  • Trace       Diagnostic    
  • Connect     Communications
  • Disconnect  Communications
  • Read        Communications
  • Receive     Communications
  • Send        Communications
  • Write       Communications
  • Block       Security      
  • Grant       Security      
  • Protect     Security      
  • Revoke      Security      
  • Unblock     Security      
  • Unprotect   Security      
  • Use         Other

Related Posts by Categories

0 comments:

Post a Comment