PowerShell is a powerful tool that can be used to do a lot of things. One of its features is the ability to add aliases. Aliases are shortcuts that are specific to a certain task or action. This can be very helpful when working with PowerShell because you can easily remember the name of a particular alias without having to type it out every time. To add an alias, you first need to create a new instance of PowerShell. Then, open the command prompt and type New-Alias . This will create a new alias for you called MyAlias . Next, you need to set up your environment variables. To do this, open the command prompt and type Set-Variable . This will set up your environment variables for you and give you access to all of the aliases that have been created for you so far. Now, let’s take a look at one of our most common aliases: $PSVersion . To use this alias, we first need to set up our environment variable $PSVersion . To do this, we open the command prompt and type Set-Variable -Name $PSVersion . This will set up your environment variable for you and give you access to all of the aliases that have been created for you so far. Now, let’s take a look at one of our most common aliases: $USERNAME . To use this alias, we first need to set up our environment variable $USERNAME . To do this, we open the command prompt and type Set-Variable -Name $USERNAME . This will set up your environment variable for you and give you access to all of the aliases that have been created for you so far.
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”
Next we’ll open PowerShell and enter:
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.
Now we can type our new shortcut “np” in the PowerShell prompt, hit enter,
and our program opens right up!
If we need to remove the alias shortcut in the future, we’ll just type:
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.
This option will make the alias unable to be altered or deleted while the session is open.
To view all the current aliases, type:
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.