Datasheet
14 CHAPTER 1
•
USING POWERSHELL WITH ACTIVE DIRECTORY
Each cmdlet has a di erent set of parameters that it recognizes. e
-ComputerName
parameter in the previous example is only relevant for the
Get-Service
cmdlet. If
you tried to pass it into the
Get-ChildItem
cmdlet, an error would be thrown:
PS C:\> Get-ChildItem -ComputerName localhost
Get-ChildItem : A parameter cannot be found that matches parameter name ‘Comput
erName’.
At line:1 char:28
+ Get-ChildItem -ComputerName <<<< localhost
+ CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterB
indingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Comm
ands.GetChildItemCommand
However, PowerShell implements some parameters that are common to all cmdlets.
ese are referred to as common parameters. You can retrieve a list of common
parameters in PowerShell by running the following command:
Get-Help about_CommonParameters
Table 1.2 lists the common parameters and describes what each does.
TABLE 1.2 Command Parameters
Name Description
-Verbose
Includes detailed information in the output of the cmdlet. This is typically
in-depth information that may not be commonly used.
-Debug
Includes programmer-level detail in the output of the cmdlet. In most
day-to-day administration tasks, the
-Debug
parameter is rarely used.
-WarningAction
Specifi es what the cmdlet should do if it encounters a warning. The pos-
sible values are
SilentlyContinue
(continue executing the cmdlet
without notifi cation),
Continue
(display a notifi cation and then continue
executing the cmdlet),
Inquire
(ask the user whether to stop or keep
going), and
Stop
(stop execution of the cmdlet).
-WarningVariable
Specifi es a variable to which warning information can be written. You can
use this variable later in other commands or scripts.
-ErrorAction
Specifi es what the cmdlet should do if it encounters an error. The pos-
sible values are
SilentlyContinue
(continue executing the cmdlet
without notifi cation),
Continue
(display a notifi cation and then continue
executing the cmdlet),
Inquire
(ask the user whether to stop or keep
going), and
Stop
(stop execution of the cmdlet).
-ErrorVariable
Specifi es a variable to which error information can be written. You can
use this variable later in other commands or scripts.
c01.indd 14c01.indd 14 5/12/2011 1:07:46 PM5/12/2011 1:07:46 PM