Datasheet
UNDERSTAND THE BASICS OF POWERSHELL 13
Administering
Service Delivery
PART I
example, if you want to get information about a speci c service on your computer,
you can run the same
Get-Service
cmdlet that you just ran, but this time specify
the name of the service as a parameter. Figure 1.7 shows the output of the
Get-
Service
cmdlet run against the Windows Update service.
FIGURE 1.7 Adding a parameter to a cmdlet
e
-Name
parameter shown in Figure 1.7 is a positional parameter. is means you
don’t have to specify
-Name
when using the parameter. If you ran the same cmdlet
but didn’t include
-Name
in the command, the cmdlet would assume that the rst
unnamed parameter was the
-Name
parameter. at makes the following two
commands identical:
Get-Service -Name “Windows Update”
Get-Service “Windows Update”
is next command is also identical to the rst two:
Get-Service -ComputerName localhost “Windows Update”
In the previous command, the rst parameter used (
-ComputerName
) is a named
parameter, because the parameter is speci ed by using
-ComputerName
in the
command, followed by the name of the computer (localhost in this case). e
second parameter wasn’t named. However, because it’s the rst unnamed parameter
in the command, the cmdlet assumes that it’s the
-Name
parameter. It’s the same as
using the following command:
Get-Service -ComputerName localhost -Name “Windows Update”
You’ll learn how to nd out which parameters are positional or named, along with
their default values, later in this chapter.
c01.indd 13c01.indd 13 5/12/2011 1:07:45 PM5/12/2011 1:07:45 PM