Speed Mastery with Your own PowerShell Aliases

Microsoft has placed great emphasis on PowerShell as the command- line tool for the future.  PowerShell is an add-on for Windows Server 2003 (it requires the .Net framework) and is installed by default on Windows 7 Enterprise and Ultimate Editions and is available as a feature on Windows Server 2008 and 2008 R2.

PowerShell uses a verb-object syntax that is unfamiliar to many administrators.  For example; to see a list of commands you must type “ get-command”. To summon the excellent built-in help you must type “get-help *”  for a list of all help topics. Since there are so many new commands to learn (called cmdlets in PowerShell), Microsoft has included the use of aliases for many the PowerShell cmdlets to ease the learning curve.

Aliases are an alternative to using the precise PowerShell cmdlet. To clear the screen we can use the aliases  “cls” or “clear” for the cmdlet” Clear-Host”.” Copy-Item” has the aliases “copy”, “cp” and “cpi”. I often prefer the alias to the cmdlet because it is usually shorter and easier to remember. For instance the change directory command is “cd” for the alias and the cmdlet is the much longer “Set-Location”.

PowerShell  v2 on Windows 7 and Server 2008 R2 includes more than a hundred aliases but you can also create your own. If you wish to display events from the Event Logs you can type the cmdlet “Get-WinEvents” or you can create your own alias. Type”Set-Alias Events Get-WinEvent” and Powershell will store your alias. Type “Events” and PowerShell will list events from the Event Logs on the screen until they are all listed or until you press control + c to stop. You can also create aliases that will launch programs such as WordPad. Try “Set-Alias wp c:\windows\write.exe” set an alias for Wordpad. Then type “wp” to launch Wordpad.

You can tailor PowerShell to your personal needs and become productive sooner with the aliases created by Microsoft and the aliases that you author yourself in PowerShell.

Author: Mark Menges

Related Courses

Automating Windows Server 2008 Administration with Windows Powershell (M6434)

Administering and Maintaining Windows 7 (M50292)

Configuring, Managing, and Maintaining Server 2008 R2 (M6419)

In this article

Join the Conversation