Understanding cmdlet syntax
We’ve already seen that you can pass information to cmdlets for input, or to modify the output. For instance, in the previous section, we typed the following:
Set-Alias -Name adapters -Value Get-NetAdapter
The cmdlet is called Set-Alias
, but there are two bits of information after that: -Name
and -Value
. These are called parameters. They are denoted by the dash character (-
), which tells PowerShell that the following characters up to the next space character represent an instruction, rather than a value. In each of the preceding parameters we’ve passed a string—we’ve told Set-Alias
that the value of -Name
is adapters
, and -Value
is Get-NetAdapter
. Now, when we type adapters
at Command Prompt, PowerShell knows to substitute it with Get-NetAdapter
.
That’s great, but how do we know which parameters a cmdlet will take? Well, we’re going to go back to our friend Get-Help
from Chapter 1, Introduction to PowerShell...