Applies to: Exchange Server 2010 SP3, Exchange Server 2010 SP2

Topic Last Modified: 2009-10-19

You can assign an Exchange Management Shell cmdlet or Cmd.exe command to an administrator-defined and easy-to-remember alias in Microsoft Exchange Server 2010. Such aliases can be handy 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.

See the following sections for more information about using aliases in the Shell:

Built-in Aliases

Creating Custom Aliases

Removing an Alias

Importing and Exporting Aliases

Alias Persistence

Alias Limitations

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 2010 by using the 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 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.

The following table shows the built-in aliases and their full names.

Built-in aliases

Alias Cmdlet Alias Cmdlet Alias Cmdlet

%

ForEach-Object

gdr

Get-PSDrive

popd

Pop-Location

?

Where-Object

ghy

Get-History

ps

Get-Process

ac

Add-Content

gi

Get-Item

pushd

Push-Location

asnp

Add-PSSnapIn

gjb

Get-Job

pwd

Get-Location

cat

Get-Content

gl

Get-Location

r

Invoke-History

cd

Set-Location

gm

Get-Member

rbp

Remove-PSBreakpoint

chdir

Set-Location

gmo

Get-Module

rcjb

Receive-Job

clc

Clear-Content

gp

Get-ItemProperty

rd

Remove-Item

clear

Clear-Host

gps

Get-Process

rdr

Remove-PSDrive

clhy

Clear-History

grid

Out-GridView

ren

Rename-Item

cli

Clear-Item

group

Group-Object

ri

Remove-Item

clp

Clear-ItemProperty

gsn

Get-PSSession

rjb

Remove-Job

cls

Clear-Host

gsnp

Get-PSSnapIn

rm

Remove-Item

clv

Clear-Variable

gsv

Get-Service

rmdir

Remove-Item

compare

Compare-Object

gu

Get-Unique

rni

Rename-Item

copy

Copy-Item

gv

Get-Variable

rnp

Rename-ItemProperty

cp

Copy-Item

gwmi

Get-WmiObject

rp

Remove-ItemProperty

cpi

Copy-Item

h

Get-History

rsn

Remove-PSSession

cpp

Copy-ItemProperty

history

Get-History

rsnp

Remove-PSSnapin

cvpa

Convert-Path

icm

Invoke-Command

rv

Remove-Variable

dbp

Disable-PSBreakpoint

iex

Invoke-Expression

rvpa

Resolve-Path

del

Remove-Item

ihy

Invoke-History

rwmi

Remove-WMIObject

diff

Compare-Object

ii

Invoke-Item

sajb

Start-Job

dir

Get-ChildItem

imo

Import-Module

sal

Set-Alias

ebp

Enable-PSBreakpoint

ipal

Import-Alias

sasv

Start-Service

echo

Write-Output

ipcsv

Import-Csv

sbp

Set-PSBreakpoint

emm

Export-ModuleMember

IPSN

Import-PSSession

sc

Set-Content

epal

Export-Alias

iwmi

Invoke-WMIMethod

select

Select-Object

epcsv

Export-Csv

kill

Stop-Process

set

Set-Variable

EPSN

Export-PSSession

list

format-list

si

Set-Item

erase

Remove-Item

lp

Out-Printer

sl

Set-Location

ETSN

Enter-PSSession

ls

Get-ChildItem

sleep

Start-Sleep

EXSN

Exit-PSSession

man

help

sort

Sort-Object

fc

Format-Custom

md

mkdir

sp

Set-ItemProperty

fl

Format-List

measure

Measure-Object

spjb

Stop-Job

foreach

ForEach-Object

mi

Move-Item

spps

Stop-Process

ft

Format-Table

mount

New-PSDrive

spsv

Stop-Service

fw

Format-Wide

move

Move-Item

start

Start-Process

gal

Get-Alias

mp

Move-ItemProperty

sv

Set-Variable

gbp

Get-PSBreakpoint

mv

Move-Item

swmi

Set-WMIInstance

gc

Get-Content

nal

New-Alias

table

format-table

gci

Get-ChildItem

ndr

New-PSDrive

tee

Tee-Object

gcm

Get-Command

ni

New-Item

type

Get-Content

gcs

Get-PSCallStack

nmo

New-Module

where

Where-Object

nv

New-Variable

nsn

New-PSSession

wjb

Wait-Job

ogv

Out-GridView

oh

Out-Host

write

Write-Output

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

Copy Code
Get-Help About_Alias

Return to top

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. However, 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 New-Mailbox cmdlet. You could then use any of the three aliases to run the New-Mailbox cmdlet. However, each alias that you create can only be assigned to the New-Mailbox cmdlet. You can't, for example, assign Alias1 to both the New-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.

The following table shows several examples of how to create a new alias.

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

Return to top

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.

The Import-Alias cmdlet reads a text file that has CSV values and brings the list into the Shell as an object. By using the Export-Alias cmdlet and Import-Alias cmdlet, you can export a list of aliases from the Shell on one computer and import them to the 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 a 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 Shell session is opened, you must add the alias definition to your Shell profile. You can modify your Shell profile by running the command Notepad $Profile. If the profile directory doesn't exist, you might have to create it first. To find out the path of your profile, run the command $Profile.

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.

Return to top

For More Information