• ARTICLES
SEARCH

How-To Geek

Adding a shortcut in PowerShell with Aliases

A hard working admin is constantly opening and closing multiple programs to get work done. When you’re working in PowerShell, we can use aliases to make switching to a new program as fast as possible.

We’ll first need to find the folder location of the program executable. We’re using Notepad in our example, which is located in “C:WindowsSystem32notepad.exe”

sshot-2010-01-01-04-33-51

Next we’ll open PowerShell and enter:

new-item alias:np -value C:WindowsSystem32notepad.exe

This states that we are assigning the Alias Name “np” to the program Notepad.exe. Once the command is run, it outputs the verification of our assigning the alias to the program.

sshot-2010-01-01-05-08-32

Now we can type our new shortcut “np” in the PowerShell prompt, hit enter,

sshot-2010-01-01-05-09-50

and our program opens right up!

sshot-2010-01-01-04-40-52

If we need to remove the alias shortcut in the future, we’ll just type:

remove-item alias:np

sshot-2010-01-01-05-12-13

If you need your alias to resist deletion, then you can add one of two available options to the end of the alias creation command:

This option will allow you to change the association of the alias or delete it during the session, but you will have to add -force to the end of the command.

new-item alias:np -value C:WindowsSystem32notepad.exe –options “ReadOnly”

This option will make the alias unable to be altered or deleted while the session is open.

new-item alias:np -value C:WindowsSystem32notepad.exe –options “Constant”

To view all the current aliases, type:

Set-Location alias:
Get-ChildItem *

sshot-2010-01-01-05-33-51

Creating shortcuts using aliases is pretty easy, and can be very useful. However, the alias definition will be removed the next time you open a PowerShell session, so if you want to make an alias permanent, you’ll have to modify your PowerShell Profile.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 01/1/10

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!