Return alias names for Cmdlets. An alias is an alternate (usually shorter) name for a cmdlet, script, function, or executable file. By default, Get-Alias takes an alias and returns the command name, with the -Definition parameter set, Get-Alias will accept a command name and return its alias.

      Get-Alias [ [-Name] string[] ]
         [-scope string] [-exclude string[] ] [CommonParameters]

      Get-Alias [-Definition string[]]
         [-scope string] [-exclude string[] ] [CommonParameters]

   -Name string[]
       The alias to retrieve. By default, all aliases defined for the current session.
       (the "-Name" is optional)

   -Definition string[]
Get the aliases for the specified item. Enter the name of a cmdlet, function, script, file, or executable.

The alias object contains a property called 'Definition' which holds this information for each Alias. -scope string The scope in which this alias is valid. Valid values are "Global", "Local", or "Script", or a number relative to the current scope ( 0 through the number of scopes, where 0 is the current scope and 1 is its parent). "Local" is the default. For more, type "get-help about_scope". -exclude string[] Omit the specified items, wildcards allowed e.g. "*ms*" CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.

Standard Aliases for Get-Alias: gal

The 'built-in' aliases supplied with PowerShell have the option AllScope set, so they will survive any changes in scope.
The 'built-in' aliases that are idiomatic to PowerShell also have the ReadOnly option set.

Aliases are primarily designed to promote high-speed interactive use of PowerShell, when writing scripts that will be shared with other users it is often better to use the full cmdlet names as this will improve the scripts readability.

You can also view aliases via the Alias provider that exposes a drive called Alias: much like a file system drive:

Set-Location alias:


Retrieve all aliases for the current session, displaying the cmdlet and the alias name:

PS C:\> get-alias

Retrieve all aliases that start with the letter S

PS C:\> get-alias -name s*

Retrieve all aliases that reference the Set-Location cmdlet:

PS C:\> get-alias | where-object {$_.Definition -eq 'Set-Location'}

Retrieve all the aliases that have the ReadOnly option set:

PS C:\> get-alias | where-object {($_.Options -split ',') -contains 'ReadOnly'}

Retrieve all aliases and display their definition and options:

PS C:\> get-alias | format-table name,definition,options -auto

#There are places I remember
All my life, though some have changed# ~ The Beatles (In My Life)

Related PowerShell Commands:

export-alias epal Export an alias list to a file
import-alias - Import an alias list from a file
new-alias - Create a new Cmdlet-alias pairing
set-alias - Map an alias to a Cmdlet

Copyright © 1999-2019
Some rights reserved