Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1, Exchange Server 2007
Topic Last Modified: 2006-08-17

In Microsoft Exchange Server 2007, you can assign an Exchange Management Shell cmdlet or Cmd.exe command to an administrator-defined and easy-to-remember alias. Such aliases can be useful when you frequently use certain cmdlets and want to reduce the typing that you must do.

When an alias is called from the command line, the rules that apply to the cmdlet that is represented by the alias are enforced exactly as when the cmdlet is called. You must supply any required parameters and their values exactly as if you had called the cmdlet name.

Built-in Aliases

Many cmdlets that are used regularly have default, or built-in, aliases assigned to them. These built-in aliases help reduce the typing that you have to do when you administer Exchange 2007 by using the Exchange Management Shell.

For example, the Get-ChildItem cmdlet resembles the MS-DOS Dir command. Because you are familiar with the Dir command, you might want to use the Dir alias when you use the Exchange Management Shell instead of typing Get-ChildItem every time that you want to view the contents of a directory. The output from the Get-ChildItem cmdlet and the Dir alias is the same and can be used interchangeably.

Table 1 shows the built-in aliases and their full names.

Table1   Built-in aliases

Alias Command Alias Command Alias Command

Ac

Add-Content

Iex

Invoke-Expression

Write

Write-Output

Asnp

Add-PSSnapin

Ihy

Invoke-History

Cat

Get-Content

Clc

Clear-Content

Ii

Invoke-Item

Cd

Set-Location

Cli

Clear-Item

Ipal

Import-Alias

Clear

Clear-Host

Clp

Clear-ItemProperty

Ipcsv

Import-Csv

Cp

Copy-Item

Clv

Clear-Variable

Mi

Move-Item

H

Get-History

Cpi

Copy-Item

Mp

Move-ItemProperty

History

Get-History

Cpp

Copy-ItemProperty

Nal

New-Alias

Kill

Stop-Process

Cvpa

Convert-Path

Ndr

New-PSDrive

Lp

Out-Printer

Diff

Compare-Object

Ni

New-Item

Ls

Get-ChildItem

Epal

Export-Alias

Nv

New-Variable

Mount

New-PSDrive

Epcsv

Export-Csv

Oh

Out-Host

Mv

Move-Item

Fc

Format-Custom

Rdr

Remove-PSDrive

Popd

Pop-Location

Fl

Format-List

Ri

Remove-Item

Ps

Get-Process

Foreach

ForEach-Object

Rni

Rename-Item

Pushd

Push-Location

%

ForEach-Object

Rnp

Rename-ItemProperty

Pwd

Get-Location

Ft

Format-Table

Rp

Remove-ItemProperty

R

Invoke-History

Fw

Format-Wide

Rsnp

Remove-PSSnapin

Rm

Remove-Item

Gal

Get-Alias

Rv

Remove-Variable

Rmdir

Remove-Item

Gc

Get-Content

Rvpa

Resolve-Path

Echo

Write-Output

Gci

Get-ChildItem

Sal

Set-Alias

Cls

Clear-Host

Gcm

Get-Command

Sasv

Start-Service

Chdir

Set-Location

Gdr

Get-PSDrive

Sc

Set-Content

Copy

Copy-Item

Ghy

Get-History

Select

Select-Object

Del

Remove-Item

Gi

Get-Item

Si

Set-Item

Dir

Get-ChildItem

Gl

Get-Location

Sl

Set-Location

Erase

Remove-Item

Gm

Get-Member

Sleep

Start-Sleep

Move

Move-Item

Gp

Get-ItemProperty

Sort

Sort-Object

Rd

Remove-Item

Gps

Get-Process

Sp

Set-ItemProperty

Ren

Rename-Item

Group

Group-Object

Spps

Stop-Process

Set

Set-Variable

Gsv

Get-Service

Spsv

Stop-Service

Type

Get-Content

Gsnp

Get-PSSnapin

Sv

Set-Variable

List

Format-List

Gu

Get-Unique

Tee

Tee-Object

Table

Format-Table

Gv

Get-Variable

Where

Where-Object

Man

ExHelp

Gwmi

Get-WmiObject

?

Where-Object

Help

ExHelp

For more information about aliases, run the following command in the Exchange Management Shell:

Copy Code
Get-Help About_Alias

Creating Custom Aliases

In addition to the default, or built-in, aliases, you can define and use custom aliases instead of the names of cmdlets that you frequently use. You can use the Set-Alias cmdlet to associate cmdlets to familiar command names that have the equivalent functionality in Cmd.exe. You can assign multiple aliases to a single command. But each alias can only be assigned to a single command. For example, you can have three aliases Alias1, Alias2, and Alias3 that are assigned to the Move-Mailbox cmdlet. You could then use any of the three aliases to run the Move-Mailbox cmdlet. However, each alias that you create can only be assigned to the Move-Mailbox cmdlet. You can't, for example, assign Alias1 to both the Move-Mailbox cmdlet and the Get-Mailbox cmdlet.

To create a new alias-cmdlet pairing, run the Set-Alias cmdlet and supply the name of the alias, together with the name of the cmdlet that you want to call when the alias is entered.

Table 2 shows several examples of how to create a new alias.

Table 2   Examples of custom aliases

Alias description Alias command

Retrieve the contents of a file.

Copy Code
Set-Alias Type Get-Content

Retrieve the listing of a directory.

Copy Code
Set-Alias Dir Get-ChildItem

Remove a file.

Copy Code
Set-Alias Erase Remove-Item

Set pad as an alias for Microsoft WordPad.

Copy Code
Set-Alias Pad "${env:programfiles}\Windows NT\Accessories\wordpad.exe"

Display the list of all defined aliases.

Copy Code
Set-Alias Aliases Get-Alias

Removing an Alias

To remove an alias, delete the alias from the alias drive. For example, an administrator creates the Ls alias by using the following command:

Copy Code
Set-Alias Ls Get-ChildItem

Later the administrator decides that the Ls alias is no longer needed and uses the following command to remove the Ls alias:

Copy Code
Remove-Item Alias Ls

Importing and Exporting Aliases

The Export-Alias cmdlet writes the current alias list to a file in comma-separated values (CSV) format. You can include the name of the file and its path in the command line. If the path doesn't exist, the cmdlet will create the path for you. You can create the file by using the .txt or .doc extensions.

The Import-Alias cmdlet reads a text file that has CSV values and brings the list into the Exchange Management Shell as an object. By using the Export-Alias cmdlet and Import-Alias cmdlet, you can export a list of aliases from the Exchange Management Shell on one computer and import them to the Exchange Management Shell on another computer. Because existing predefined aliases exist on both computers, all alias name conflicts will be ignored and not imported.

Alias Persistence

Aliases that are created from the command line by using the Set-Alias cmdlet during an Exchange Management Shell session can be used when the session is active. After the session is closed, the alias definition is lost. To make a user-defined alias persistent and available every time that a new Exchange Management Shell session is opened, you must add the alias definition to the Exchange Management Shell Microsoft.PowerShell_Profile.ps1 file that is located in the My Documents\PSConfiguration subfolder of your user profile directory.

Alias Limitations

Although aliases can be defined for cmdlets and used instead of cmdlet names, you can't include parameters in the definition of the aliases that you define. You must provide parameters as needed when the alias is called, exactly as you would if you called the cmdlet.