Cmdlets Use Verb-Noun Names to Reduce Command Memorization in Windows PowerShell
Windows PowerShell uses a "verb-noun" naming system, where each cmdlet name consists of a standard verb hyphenated with a specific noun. Windows PowerShell verbs are not always English verbs, but they express specific actions in Windows PowerShell. Nouns are very much like nouns in any language, they describe specific types of objects that are important in system administration. It is easy to demonstrate how these two-part names reduce learning effort by looking at a few examples of verbs and nouns.
Nouns are less restricted, but they should always describe what a command acts upon. Windows PowerShell has commands such as Get-Process, Stop-Process, Get-Service, and Stop-Service.
In the case of two nouns and two verbs, consistency does not simplify learning that much. However, if you look at a standard set of 10 verbs and 10 nouns, you then have only 20 words to understand, but those words can be used to form 100 distinct command names.
Frequently, you can recognize what a command does by reading its name, and it is usually apparent what name should be used for a new command. For example, a computer shutdown command might be Stop-Computer. A command that lists all computers on a network might be Get-Computer. The command that gets the system date is Get-Date.
You can list all commands that include a particular verb with the -Verb parameter for Get-Command (We will discuss Get-Command in detail in the next section). For example, to see all cmdlets that use the verb Get, type:
| PS> Get-Command -Verb Get CommandType Name Definition ----------- ---- ---------- Cmdlet Get-Acl Get-Acl [[-Path] <String[]>]... Cmdlet Get-Alias Get-Alias [[-Name] <String[]... Cmdlet Get-AuthenticodeSignature Get-AuthenticodeSignature [-... Cmdlet Get-ChildItem Get-ChildItem [[-Path] <Stri... ... |
The -Noun parameter is even more useful because it allows you to see a family of commands that affect the same type of object. For example, if you want to see which commands are available for managing services, type following command:
| PS> Get-Command -Noun Service CommandType Name Definition ----------- ---- ---------- Cmdlet Get-Service Get-Service [[-Name] <String... Cmdlet New-Service New-Service [-Name] <String>... Cmdlet Restart-Service Restart-Service [-Name] <Str... Cmdlet Resume-Service Resume-Service [-Name] <Stri... Cmdlet Set-Service Set-Service [-Name] <String>... Cmdlet Start-Service Start-Service [-Name] <Strin... Cmdlet Stop-Service Stop-Service [-Name] <String... Cmdlet Suspend-Service Suspend-Service [-Name] <Str... ... |
A command is not necessarily a cmdlet, just because it has a verb-noun naming scheme. One example of a native Windows PowerShell command that is not a cmdlet but has a verb-noun name, is the command for clearing a console window, Clear-Host. The Clear-Host command is actually an internal function, as you can see if you run Get-Command against it:
| PS> Get-Command -Name Clear-Host CommandType Name Definition ----------- ---- ---------- Function Clear-Host $spaceType = [System.Managem... |