Get-Alias

NAME
    Get-Alias

SYNOPSIS
    Gets the Aliases for the current session.

SYNTAX
    Get-Alias [[-Name] <string[]>] [-Exclude <string[]>] [-Scope <string>] [<CommonParameters>]

    Get-Alias [-Definition <string[]>] [-Exclude <string[]>] [-Scope <string>] [<CommonParameters>]

DESCRIPTION
    The Get-Alias cmdlet gets the Aliases (alternate names for commands and executable files) in the current session. This includes built-in Aliases, Aliases that you have set or imported, and Aliases that you have added to your Windows PowerShell profile.

    By default, Get-Alias takes an Alias and returns the command name. When you use the Definition parameter, Get-Alias takes a command name and returns its Aliases.

PARAMETERS
    -Definition <string[]>
        Gets the Aliases for the specified item. Enter the name of a cmdlet, Function, script, file, or executable file.

        This parameter is called Definition, because it searches for the item name in the Definition property of the Alias object.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? true

    -Exclude <string[]>
        Omits the specified items. The value of this parameter qualifies the Name and Definition parameters. Enter a name, a definition, or a pattern, such as “s*”. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Name <string[]>
        Specifies the Aliases to retrieve. Wildcards are permitted. By default, Get-Alias retrieves all Aliases defined for the current session. The parameter name (“Name”) is optional. You can also pipe Alias names to Get-Alias.

        Required?                    false
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue, ByPropertyName)
        Accept wildcard characters? false

    -Scope <string>
        Gets only the Aliases in the specified scope. 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 information, see about_scopes.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe Alias names to Get-Alias.

OUTPUTS
    System.Management.Automation.AliasInfo
        Get-Alias returns an object that represents each Alias.

NOTES

        An Alias is an alternate name or nickname for a cmdlet, Function, or an executable file. To run the cmdlet, Function, or executable, you can use its full name or any Alias. For more information, see about_aliases.

        To create a new Alias, use Set-Alias or New-Alias. To delete an Alias, use Remove-Item.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Get-Alias

    Description
    ———–
    This command gets all Aliases in the current session.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Get-Alias -Name g*, s* -Exclude get-*

    Description
    ———–
    This command gets all Aliases that begin with “g” or “s”, except for Aliases that begin with “get-“.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Get-Alias -definition Get-ChildItem

    Description
    ———–
    This command gets the Aliases for the Get-ChildItem cmdlet.

    By default, the Get-Alias cmdlet gets the item name when you know the Alias. The Definition parameter gets the Alias when you know the item name.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Get-Alias | Where-Object {$_.Options -match “ReadOnly”}

    Description
    ———–
    This command retrieves all Aliases in which the value of the Options property is ReadOnly. This command provides a quick way to find the Aliases that are built into Windows PowerShell, because they have the ReadOnly option.

    Options is just one property of the AliasInfo objects that Get-Alias gets. To find all properties and methods of AliasInfo objects, type “Get-Alias | Get-Member“.

    ————————– EXAMPLE 5 ————————–

    C:\PS>Get-Alias -definition “*-pssession” -Exclude e* -Scope global

    Description
    ———–
    This example gets Aliases for commands that have names that end in “-pssession”, except for those that begin with “e”.

    The command uses the Scope parameter to apply the command in the global scope. This is useful in scripts when you want to get the Aliases in the session.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113306
    about_aliases
    Set-Alias
    New-Alias
    Export-Alias
    Import-Alias
    Alias Provider