Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Powershell's New-Alias and Set-Alias cmdlets?

Tags:

powershell

Other than Set-Alias being able to change extant aliases, what's the difference between these commands?

Why would someone use New-Alias over Set-Alias?

like image 809
Rebecca Moore Avatar asked Jan 04 '18 10:01

Rebecca Moore


People also ask

Which cmdlet creates a new alias in the alias provider set?

The New-Alias cmdlet creates a new alias in the current PowerShell session. Aliases created by using New-Alias are not saved after you exit the session or close PowerShell. You can use the Export-Alias cmdlet to save your alias information to a file.

What are the aliases for get Location cmdlet?

The Get-Alias cmdlet gets the aliases in the current session. This includes built-in aliases, aliases that you have set or imported, and aliases that you have added to your PowerShell profile. By default, Get-Alias takes an alias and returns the command name.


1 Answers

One (the only one?) advantage in using new-alias is that you will get an error when you override an existing alias. Otherwise they are synonyms when it comes to alias creation, to quote from help -full new-alias:

To create a new alias, use Set-Alias or New-Alias. To change an alias, use Set-Alias.

like image 179
Ocaso Protal Avatar answered Sep 28 '22 23:09

Ocaso Protal