Return alias names for Cmdlets. 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.
Syntax
Get-Alias [ [-Name] string[] ]
[-scope string] [-exclude string[] ] [CommonParameters]
Get-Alias [-Definition string[]]
[-scope string] [-exclude string[] ] [CommonParameters]
Key
-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.
You can also view aliases via the Alias provider that exposes a drive called Alias: much like a file system drive:
Set-Location alias:
Get-Childitem
Examples
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 -match "Set-Location"}
Retrieve all built-in aliases (these have the ReadOnly option set):
PS C:\> get-alias | where-object {$_.Options -match "ReadOnly"}
#There are places I remember
All my life, though some have changed# - The Beatles (In My Life)
Related:
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 SS64.com 1999-2013
Some rights reserved