# How to overwrite or remove PowerShell alias?

PowerShellMicrosoft TechnologiesSoftware & Coding

You can overwrite the Powershell alias by redefining it. For example, if the alias is created Edit for Notepad.exe and if you want to overwrite it with another program, say wordpad.exe then use the below command.

We will overwrite the Edit alias cmdlet with Wordpad.exe using the Set-Alias command. When you close the PowerShell session, it will remove newly created aliases and modified aliases.

Set-Alias edit "C:\Program Files\Windows NT\Accessories\wordpad.exe"

You cannot overwrite pre-defined aliases. It will throw an exception.

For example, when you try to modify dir alias which points to Get-Content, error output will be as below.

To remove newly created aliases without closing the PowerShell console, you need to use RemoveAlias command.

Remove-Alias -AliasName Edit

You can also use Del command to remove the alias.

Del alias:Edit

Again you cannot remove the Aliases which are permanent. Only newly created aliases can be removed and automatically deleted when the session ends.

Published on 14-Feb-2020 07:03:20