Alias

An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or executable file. You can use the alias instead of the command name in any PowerShell commands.

ALIAS CMDLETS

Get-Alias

Gets all the aliases in the current session.

Set-Alias

Creates or changes an alias.

New-Alias

Creates a new alias.

Export-Alias

Exports one or more aliases to a file.

Import-Alias

Imports an alias file into PowerShell.

CREATING AN ALIAS

To create a new alias, use the New-Alias cmdlet.

New-Alias -Name gh -Value Get-Help

Set-Alias

Creates or changes an alias for a cmdlet or other command in the current PowerShell session.

Set-Alias -Name list -Value Get-ChildItem

GETTING ALIASES

To get all the aliases in the current session, including the built-in aliases, the aliases in your PowerShell profiles, and the aliases that you have created in the current session, type:

Get-Alias

Export-Alias

Exports information about currently defined aliases to a file.

Export-Alias -Path "alias.csv"

Import-Alias

Imports an alias list from a file.

Import-Alias test.txt

SAVING ALIASES

The aliases that you create are saved only in the current session. To use the aliases in a different session, add the alias to your PowerShell profile. Or, use the Export-Alias cmdlet to save the aliases to a file.