Click to Rate and Give Feedback
TechNet
TechNet Library
Scripting
Script Center
Windows PowerShell
Cmdlets
 Using the New-Alias Cmdlet
What Can I Do With Windows PowerShell?
Using the New-Alias Cmdlet

Creating a New Windows PowerShell Alias

So you say that you like Windows PowerShell, but you have problems remembering some of the cmdlet names? Well, then why not create an alias for those cmdlets, an alias that you can remember? For example, maybe you’d prefer to type show instead of Get-ChildItem. If that’s the case, then you can use the New-Alias cmdlet to map the term show to Get-ChildItem. All you have to do is call New-Alias followed by the alias name (show) and the cmdlet the alias is being mapped to (Get-ChildItem). You know, something like this:


New-Alias show Get-ChildItem

Now, what do you suppose will happen the next time you type show in the Windows PowerShell console? You got it:

Windows PowerShell


By default, aliases are not saved between Windows PowerShell sessions: each time you restart Windows PowerShell you’ll need to recreate the alias. To ensure that your new aliases survive between Windows PowerShell sessions, create a PSConfiguration folder in your Windows PowerShell profile folder. For example:


C:\Documents and Settings\gstemp\My Documents\PSConfiguration

Note. How are you supposed to know your Windows PowerShell profile folder? Just type this command:


Get-Variable profile | Format-List

In the PSConfiguration folder, create a file named Microsoft.PowerShell_profile.ps1 and add the following command to the file:


Set-Alias show Get-ChildItem

That should do the trick.

New-Alias Aliases
  • nal

Related Links

© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker