Skip to content

PowerShell Alias

How PowerShell aliases work, including built-in shortcuts like ls, cat, and dir, and how to create, manage, and persist custom aliases, and best practices for scripting.

An alias is an alternate name, nickname, or shorthand reference assigned to a cmdlet, function, script, or executable file. PowerShell includes built-in aliases to help administrators transition from Unix shells (Bash) and Windows Command Prompt (cmd.exe), as well as cmdlets to create and manage custom aliases.

PowerShell ships with many built-in aliases, including familiar names from Bash (ls, cat, rm) and Command Prompt (dir, copy, del), to ease the transition for users coming from other shells.

Inspecting Aliases with Get-Alias

The Get-Alias cmdlet (alias: gal) inspects the aliases registered in your active PowerShell session.

Finding the Target of an Alias

To find out what cmdlet or executable an alias points to, pass the alias name directly:

Consolepowershell
Get-Alias -Name "dir", "ls", "cat"
Outputplaintext
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           dir -> Get-ChildItem
Alias           ls -> Get-ChildItem
Alias           cat -> Get-Content

where:

  • -Name ls looks up the specific alias ls.
  • The output shows ls resolves to the Get-ChildItem cmdlet.

To see every alias currently defined in the session, run Get-Alias with no parameters:

Consolepowershell
Get-Alias | Select-Object -First 5
Outputplaintext
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           %  -> ForEach-Object
Alias           ?  -> Where-Object
Alias           ac -> Add-Content
Alias           cat -> Get-Content
Alias           cd  -> Set-Location

Reverse Lookup: Finding Aliases for a Cmdlet

You can also search in the reverse direction, finding all aliases that point to a specific cmdlet, using the -Definition parameter:

Consolepowershell
Get-Alias -Definition Get-ChildItem
Outputplaintext
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           dir -> Get-ChildItem
Alias           gci -> Get-ChildItem
Alias           ls -> Get-ChildItem

Common Built-In Aliases

PowerShell provides standard aliases that mirror traditional command names from Bash and Command Prompt:

Traditional Command PowerShell Alias Target Purpose / Action
dir / ls Get-ChildItem Lists items in a directory or provider path
cd / chdir Set-Location Changes the current working directory
copy / cp Copy-Item Copies files, directories, or registry items
move / mv Move-Item Moves or renames files and containers
del / rm / erase Remove-Item Deletes files, directories, or variables
cat / type Get-Content Reads and outputs the contents of a text file
cls / clear Clear-Host Clears the terminal screen buffer
ps Get-Process Queries active system processes
kill Stop-Process Terminates one or more processes by ID or name
man / help Get-Help Opens command documentation and syntax help
pwd Get-Location Displays the current working directory
echo Write-Output Writes objects to the pipeline

Creating and Managing Aliases: Set-Alias and New-Alias

PowerShell provides two cmdlets for defining aliases:

  • New-Alias: Creates an alias. If the alias already exists, it throws an error unless -Force is specified.
  • Set-Alias (alias: sal): Creates an alias if it does not exist, or overwrites it if it does. This is generally preferred.

Set-Alias

Set-Alias creates a new alias, or overwrites an existing one if the name is already in use.

Consolepowershell
Set-Alias -Name gp -Value Get-Process
gp

where:

  • -Name gp defines the alias name.
  • -Value Get-Process specifies the cmdlet the alias points to.
Outputplaintext
 NPM(K)    PM(M)      WS(M)     CPU(s)      Id  SI ProcessName
 ------    -----      -----     ------      --  -- -----------
     45   210.34     315.67      45.22    8192   1 chrome

New-Alias

New-Alias creates a new alias but throws an error if the alias name already exists, preventing accidental overwrites.

Consolepowershell
New-Alias -Name gp -Value Get-Process
Outputplaintext
New-Alias : An alias with the name 'gp' already exists.

Defining a Simple Alias

Consolepowershell
Set-Alias -Name "gh" -Value Get-Help

Set-Alias -Name "np" -Value "$env:SystemRoot\notepad.exe"

Removing an Alias

To delete an alias from the current session, use Remove-Alias or delete it from the Alias: PSDrive using Remove-Item:

Consolepowershell
Remove-Alias -Name "gh"

Remove-Item -Path "Alias:\np"

The Parameter Limitation of Aliases

An alias in PowerShell is strictly an alternate name for a command. You cannot include parameters or arguments in an alias definition.

Set-Alias -Name "ll" -Value "Get-ChildItem -Force"

If you need a shortcut that includes default parameters, write a wrapper function instead:

Consolepowershell
function ll { Get-ChildItem -Force $args }

where $args passes any additional arguments passed to ll directly through to Get-ChildItem.

Aliases can also point to custom functions, not just built-in cmdlets:

custom-function-alias.ps1powershell
function Get-DiskSummary {
    Get-Volume | Select-Object DriveLetter, SizeRemaining, Size
}

Set-Alias -Name disksum -Value Get-DiskSummary
disksum
Consolepowershell
./custom-function-alias.ps1
Outputplaintext
DriveLetter SizeRemaining        Size
----------- -------------        ----
C           123456789012 512110190592

Persisting Aliases via PowerShell Profile

Aliases created at the command line exist only in memory for the lifetime of that session. When you close the terminal, all custom aliases are lost.

To make custom aliases available in every new session, add them to your PowerShell Profile script ($PROFILE).

Step 1: Open the Profile

Locate and edit the profile file stored in the $PROFILE variable:

Consolepowershell
if (-not (Test-Path -Path $PROFILE)) {
    New-Item -ItemType File -Path $PROFILE -Force | Out-Null
}
notepad.exe $PROFILE

For more details on profile scopes and paths, see PowerShell Environment.

Step 2: Add Alias and Function Declarations

Append your custom shortcuts to the profile file:

Microsoft.PowerShell_profile.ps1powershell
Set-Alias -Name "np" -Value "$env:SystemRoot\notepad.exe"
Set-Alias -Name "sysinfo" -Value Get-ComputerInfo
Set-Alias -Name "gs" -Value Get-Service
Set-Alias -Name "gp" -Value Get-Process
Set-Alias -Name "disksum" -Value Get-DiskSummary

function ll { Get-ChildItem -Force -Color $args }
function grep { Select-String $args }

where Each Set-Alias line runs automatically every time a new PowerShell session starts, since it's part of the profile script.

Save and close the file. The aliases and functions will now load automatically whenever you launch PowerShell.

Practical Example: Managing and Exporting Session Aliases

The following script audits the current session for custom aliases, exports them to a configuration file, and demonstrates how to handle shortcuts that require default parameters:

manage-session-aliases.ps1powershell
Set-Alias -Name "procs" -Value Get-Process

function Search-LogFiles {
    param([string]$Pattern)
    Get-ChildItem -Path "$env:TEMP" -Filter "*.log" -Recurse | 
        Select-String -Pattern $Pattern
}
Set-Alias -Name "slog" -Value Search-LogFiles

$TargetAliases = "procs", "slog"

$Report = foreach ($aliasName in $TargetAliases) {
    $aliasItem = Get-Alias -Name $aliasName -ErrorAction SilentlyContinue
    if ($aliasItem) {
        [PSCustomObject]@{
            AliasName       = $aliasItem.Name
            TargetCommand   = $aliasItem.Definition
            CommandCategory = (Get-Command -Name $aliasItem.Definition).CommandType
            CreatedDate     = (Get-Date -Format "yyyy-MM-dd")
        }
    }
}

$Report

where:

  • Set-Alias -Name "procs" -Value Get-Process creates a standard command alias.
  • function Search-LogFiles wraps a multi-parameter command so it can be called with default behavior, and is then aliased to slog.
  • Get-Alias -Name $aliasName queries the alias objects directly.
  • (Get-Command -Name $aliasItem.Definition).CommandType resolves whether the target is a Cmdlet or a Function.

Execute the script from the console:

Consolepowershell
pwsh ./manage-session-aliases.ps1
Outputplaintext
AliasName TargetCommand   CommandCategory CreatedDate
--------- -------------   --------------- -----------
procs     Get-Process              Cmdlet 2026-09-27
slog      Search-LogFiles        Function 2026-09-27
Navigation