Datasheet
12 CHAPTER 1
•
USING POWERSHELL WITH ACTIVE DIRECTORY
Cmdlets are precompiled and can be run from the PowerShell command interpreter
directly or be used in a script. ey’re surprisingly exible and can be used in a
variety of ways.
PowerShell has several cmdlets built in, and applications can provide their own cmd-
lets as well. For example, Active Directory adds 76 additional cmdlets to PowerShell
when the module is installed. In fact, anyone can write a cmdlet to be used in
PowerShell; the process for writing a cmdlet is well documented by Microso .
Execute Cmdlets
When it comes down to it, executing cmdlets is as easy as opening PowerShell and
typing in the name of the cmdlet, as was demonstrated in Figure 1.5.
Basic Cmdlet Structure
When you work with cmdlets long enough, you’ll start to notice some similarities
between them. Most cmdlets start with a verb, such as
Get
,
Set
,
Add
, or
Remove
.
Usually following the verb is a noun, such as
Process
. is common structure used
in cmdlets is referred to as a verb-noun pair. For example, in the
Get-Process
cmdlet,
the verb (
Get
) tells the cmdlet that it’s retrieving information for the noun (
Process
).
All cmdlets are singular, so you’ll never see a cmdlet called
Get-Processes
.
Executing a cmdlet is as simple as opening up PowerShell and running the cmdlet:
1. Open PowerShell by choosing Start
‚
All Programs
‚
Accessories
‚
Windows PowerShell
‚
Windows PowerShell.
You can also launch PowerShell by clicking the icon in the taskbar, as shown
in Figure 1.6. A er PowerShell loads, you’re presented with the cursor, ready
to accept your command.
FIGURE 1.6 Launching PowerShell via the icon in the taskbar
2. Type in the cmdlet, and press Enter. For example, to get a list of the services
currently installed on the computer, you can run the
Get-Service
cmdlet.
Parameters
You can also feed a cmdlet parameters that in uence the behavior of the cmd-
let when it’s run. To specify a parameter, append it to the end of the cmdlet. For
c01.indd 12c01.indd 12 5/12/2011 1:07:45 PM5/12/2011 1:07:45 PM










