Datasheet
UNDERSTAND THE BASICS OF POWERSHELL 15
Administering
Service Delivery
PART I
Name Description
-OutVariable
Specifi es a variable to which you want to write the output objects.
-OutBuffer
Determines how many objects are in the output buff er before the objects
are passed through the pipeline. This is an advanced parameter that you
probably won’t use frequently, if at all.
NOTE
Cmdlets and their parameters aren’t case sensitive. However, it’s a good practice
to use capitalization for cmdlets that other people might read, such as when writing scripts.
This increases the readability of the command without aff ecting the syntax of the cmdlet.
Aliases
If you’ve already been using PowerShell, you may have noticed that not all of the
cmdlets you’ve run have conformed to the structure discussed earlier. For example,
the
dir
command doesn’t conform to the verb-noun pair syntax. e reason for
this is that
dir
is really an alias. In PowerShell, an alias is an alternate name that
you can give to command elements, such as cmdlets and scripts, to make them eas-
ier for users to run. When you execute the
dir
alias, the cmdlet that is really being
run is
Get-ChildItem
. You don’t have to use an alias; if you wanted to, you could
run the
Get-ChildItem
cmdlet directly. However, the
dir
alias saves you time;
and if you’re used to typing
dir
into a Windows command prompt to get a listing
of les and directories, then this alias makes PowerShell a little more intuitive and
uses the muscle memory you’ve built up over the years.
You aren’t limited to one alias per command. If you have a Unix or Linux back-
ground, then you’re probably more likely to use the
ls
command for listing les
and directories. For this reason,
ls
is also an alias to the
Get-ChildItem
cmdlet.
To create your own alias, you can run the
New-Alias
cmdlet. You’ll need to pass in
the name for the alias and the command element for which you’re creating the alias.
e following example creates an alias called
d
for the
Get-ChildItem
cmdlet. If
you create this alias, then you only need to type
d
instead of
dir
or
ls
to get a
listing of les and directories in PowerShell:
New-Alias -Name d -Value Get-ChildItem
Earlier in this chapter, you learned about using pro les to customize the PowerShell
environment for di erent users. You can add your commonly used aliases to your
pro le so that your aliases are loaded every time you open PowerShell.
c01.indd 15c01.indd 15 5/12/2011 1:07:46 PM5/12/2011 1:07:46 PM