Skip to content

33. Aliases

Note

The below information is extensively based in information taken from the PowerShell® Notes for Professionals book. I plan to extend this information based on my day to day usage of the language.

33.1: Get-Alias

To list all aliases and their functions:

1
Get-Alias

To get all aliases for specific cmdlet:

1
get-alias - Definition Get-ChildItem
1
2
3
4
5
CommandType Name Version Source
----------- ---- ------- ------
Alias dir -> Get-ChildItem
Alias gci -> Get-ChildItem
Alias ls -> Get-ChildItem

To find aliases by matching:

1
get-alias -Name p*
1
2
3
4
5
6
7
CommandType Name Version Source
----------- ---- ------- ------
Alias popd -> Pop-Location
Alias proc -> Get-Process
Alias ps -> Get-Process
Alias pushd -> Push-Location
Alias pwd -> Get-Location

33.2: Set-Alias

This cmdlet allows you to create new alternate names for exiting cmdlets

1
2
Set-Alias -Name proc -Value Get-Process
proc
1
2
3
4
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id SI ProcessName
------- ------ ----- ----- ----- ------ -- -- -----------
292 17 13052 20444 ... 19 7.94 620 1 ApplicationFrameHost
....

Keep in mind that any alias you create will be persisted only in current session. When you start new session you need to create your aliases again. Powershell Profiles (see [topic not yet created]) are great for these purposes.