Deleting Aliases in PowerShell

Once one creates aliases, at times they find one or two must be deleted. In this tutorial, you will learn how to delete the aliases you've created in PowerShell.

Setup

If you have not already done so, click open Windows PowerShell ISE.

The concept…

Deleted aliases isn't complicated at all, as a matter-of-fact, the opposite of New-Item is Remove-Item. If you want to get rid of the se alias you created in the previous tutorial (Creating Aliases in PowerShell), you can run this line:

Example

Remove-Item alias: se
    

Copy and Try it

You can also delete multiple aliases at once. If you just so happened to create a slew of aliases like thealias1, thealias2, etc., then all you would need to do is delete all that appear like it right? Use the following code and simply replace the "thealias#" with your alias name of course.

Example

Remove-Item alias: thealias*
    

Copy and Try it

If the alias you are removing just so happens to be defined with the ReadOnly option, you have to use the Force parameter to get rid of it (otherwise PSH will output an error that it can't be deleted). Implement the force parameter like so:

Example

Remove-Item alias: se -force 
    

Copy and Try it

Remarks last but not least…

A rather short tutorial, surely you would agree. Just a little simpler if we split the concepts up. You will come to find aliases quite handy at times. Join us next time for additional Windows PowerShell tutorial