Get Alias - PowerShell
Overview
Get-Alias retrieves aliases defined in the current PowerShell session or from a specified module. Aliases provide alternative, shorter names for commands, functions, and scripts.
Syntax
Get-Alias [-Name] <string[]> [-Definition] <string[]> [-Module] <string[]> [-Version] <string[]>
[-All] [-Format {table | list | custom}] [-Wait] [-ErrorAction {Stop | Continue | SilentlyContinue}]
[-ErrorVariable <string>] [-OutFile <string>] [-OutVariable <string>] [-PassThru] [-WhatIf]
[-Confirm] [-Filter <string>] [-ThrottleLimit <int>] [-IncludeHidden]
Options/Flags
- -Name: Retrieves aliases with the specified name or alias patterns.
- -Definition: Filters aliases by their definition, including wildcards.
- -Module: Lists aliases from the specified module name, version, or path.
- -Version: Retrieves aliases from the specified module version or range.
- -All: Returns all aliases, including aliases hidden by higher-precedence aliases.
- -Format: Specifies the output format.
- -Wait: Waits for the command to complete before returning.
- -ErrorAction: Specifies how errors are handled.
- -ErrorVariable: Assigns errors to the specified variable.
- -OutFile: Saves the output to the specified file.
- -OutVariable: Assigns the output to the specified variable.
- -PassThru: Passes the retrieved aliases to the pipeline.
- -WhatIf: Displays what would happen without actually performing the action.
- -Confirm: Prompts for confirmation before executing the command.
- -Filter: Filters aliases based on a specified expression.
- -ThrottleLimit: Sets the maximum number of concurrent operations.
- -IncludeHidden: Includes hidden aliases in the output.
Examples
Example 1: Get all aliases
Get-Alias
Example 2: Get aliases with a specific name
Get-Alias -Name Get*
Example 3: Get aliases defined in the PSSnapIn module
Get-Alias -Module PSSnapIn
Common Issues
- Aliases not found: Ensure the specified aliases exist or check for typos.
- Output formatting errors: Use
-Format table
or-Format list
to improve readability. - Hidden aliases: Use
-IncludeHidden
to display aliases hidden by higher-precedence ones.
Integration
- Combine with New-Alias to create custom aliases.
- Use Get-Command to find commands associated with specific aliases.
- Utilize Import-Module to load modules and access aliases from other modules.
Related Commands
- New-Alias
- Remove-Alias
- Set-Alias
- Get-Command