- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create new alias with PowerShell?
Anyone can create a new alias which is a shortcut to another command. To create your own alias you need to use Set-Alias cmdlet. Here, we will create a new alias Edit, which will open a Notepad.exe. First, we will check if Edit alias exists or not.
$Alias:Edit
As this is going to be a new Alias there will be no output for it. Now, we will create new alias by the below command. You can provide any program path and create an alias for it.
Set-Alias Edit Notepad.exe
Just check if this Edit alias created successfully or not.
PS E:\scripts\Powershell> $Alias:Edit Notepad.exe
This new alias is not permanent. Once you close the PowerShell console, all newly created aliases will be discarded. But the built-in alias will still remain.
If you want to create an alias permanently you have few options.
Manually each time − You need to set the alias each time when PowerShell console starts but this is not a feasible option.
Import and Export − You can export the newly created alias and import it when the PowerShell starts.
Save Alias in Profile − You can add your alias to your profile path. So when the profile starts, the alias will be created automatically when PowerShell starts.