Simple PowerShell commands
Now that we know all the ways that can get a PowerShell session started, what can we do in a PowerShell session? I like to introduce people to PowerShell by pointing out that most of the command-line tools that they already know work fine in PowerShell. For instance, try using DIR
, CD
, IPCONFIG
, and PING
. Commands that are part of Command Prompt (think DOS commands) might work slightly different in PowerShell if you look closely, but typical command-line applications work exactly the same as they have always worked in Command Prompt:
PowerShell commands, called cmdlets
, are named with a verb-noun convention. Approved verbs come from a list maintained by Microsoft and can be displayed using the get-verb
cmdlet:
By controlling the list of verbs, Microsoft has made it easier to learn PowerShell. The list is not very long and it doesn't contain verbs that have the same meaning (such as Stop, End, Terminate, and Quit), so once you learn a cmdlet using a specific verb, you can easily guess the meaning of the cmdlet names that include the verb.
Some other easy to understand cmdlets are:
Clear-Host
(clears the screen)Get-Date
(outputs the date)Start-Service
(starts a service)Stop-Process
(stops a process)Get-Help
(shows help about something)
Note that these use several different verbs. From this list, you can probably guess what cmdlet you would use to stop a service. Since you know there's a Start-Service
cmdlet, and you know from the Stop-Process
cmdlet that Stop is a valid verb, it is logical that Stop-Service
is what you would use. The consistency of PowerShell cmdlet naming is a tremendous benefit to learners of PowerShell, and it is a policy that is important as you write the PowerShell code.
Tip
What is a cmdlet?
The term cmdlet was coined by Jeffery Snover, the inventor of PowerShell to refer to the PowerShell commands. The PowerShell commands aren't particularly different from other commands, but by giving a unique name to them, he ensured that PowerShell users would be able to use search engines to easily find PowerShell code simply by including the term cmdlet.