Datasheet
UNDERSTAND THE BASICS OF POWERSHELL 25
Administering
Service Delivery
PART I
FIGURE 1.10 Listing the currently used variables
In addition to variables that you de ne yourself, there are special variables called
shell variables built into PowerShell. Shell variables are automatically created
by PowerShell. An example of a shell variable is
$null
, which always means
that something has no value. For example, if you had an Active Directory user
object and you wanted to clear the
Description
attribute, you could set the
Description
property to
$null
. is can be accomplished with the following
command:
Set-ADUser “Lincoln Alexander” -Description $null
ere are many other shell variables in PowerShell. Table 1.5 lists some of the more
common shell variables you’ll encounter.
TABLE 1.5 Common Shell Variables
Variable Description
$_
Refers to the current object that is being processed in a pipeline or a loop.
$Error
When an error is encountered in the command, the error is stored here.
$Home
The home directory of the current user.
$true
Represents the condition
True
.
$false
Represents the condition
False
.
$null
Represents a null entry, meaning the property is blank.
c01.indd 25c01.indd 25 5/12/2011 1:07:49 PM5/12/2011 1:07:49 PM