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
?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With