PowerShell Aliases: Create Shortcuts for Commands

You’ve already been using PowerShell aliases without knowing it — ls, dir, cd, and cls all work in PowerShell, and they’re all built-in aliases. PowerShell aliases are shortcut names that map to full cmdlet names, and you can create your own to reduce repetitive typing. This post covers how to find existing aliases, create new ones, work around the arguments limitation, and persist your custom aliases across sessions.
List All Built-In Aliases
Get-Alias returns all currently defined aliases. PowerShell ships with over 160 built-in aliases for common cmdlets and to provide familiar names for Unix and CMD users.
# List all aliases
Get-Alias | Sort-Object Name | Format-Table Name, Definition, Description
Name Definition Description
---- ---------- -----------
? Where-Object
% ForEach-Object
cat Get-Content
cd Set-Location
cls Clear-Host
cp Copy-Item
dir Get-ChildItem
echo Write-Output
gci Get-ChildItem
kill Stop-Process
ls Get-ChildItem
mv Move-Item
pwd Get-Location
rm Remove-Item
...
# Find the alias for a specific cmdlet
Get-Alias | Where-Object Definition -eq "Get-ChildItem"
# Look up what an alias points to
Get-Alias -Name ls
Create an Alias with Set-Alias
Set-Alias maps a short name to any cmdlet, function, or executable. The alias only persists for the current session unless you add it to your profile.
# Create simple aliases
Set-Alias -Name np -Value notepad
Set-Alias -Name gs -Value Get-Service
Set-Alias -Name gp -Value Get-Process
# Use the alias immediately
gs wuauserv # Same as: Get-Service wuauserv
# Alias to a function (best for complex shortcuts)
function Start-AdminSession { Start-Process pwsh -Verb RunAs }
Set-Alias -Name admin -Value Start-AdminSession
Aliases with Arguments — Use Functions Instead
PowerShell aliases map a name to a cmdlet only — you cannot include arguments in an alias definition. Set-Alias ll "Get-ChildItem -Force" does not work. For shortcuts that need default arguments, define a function instead.
# WRONG — this does not work
# Set-Alias ll "Get-ChildItem -Force" # -Force is not accepted here
# CORRECT — use a function wrapper
function ll { Get-ChildItem -Force @args }
function la { Get-ChildItem -Force -Hidden @args }
function lll { Get-ChildItem | Sort-Object LastWriteTime -Descending | Select-Object -First 20 }
Using @args (the splatted args automatic variable) passes any additional arguments you supply through to the underlying cmdlet.
Remove an Alias
Use Remove-Alias (PowerShell 6.1+) or Remove-Item Alias:\aliasname on older versions to delete an alias from the current session.
# PowerShell 6.1+
Remove-Alias -Name gs
# Older PowerShell / Windows PowerShell
Remove-Item -Path Alias:\gs
# Verify it's gone
Get-Alias -Name gs -ErrorAction SilentlyContinue
Export and Import Aliases
Export your current aliases to a CSV and reimport them in another session. This is useful for sharing your alias configuration or for backup purposes.
# Export all current aliases to CSV
Export-Alias -Path "C:\Logs\my-aliases.csv" -Force
# Import aliases from file in a new session
Import-Alias -Path "C:\Logs\my-aliases.csv" -Force
Persist Aliases in Your Profile
Aliases created with Set-Alias only last for the current session. To make them permanent, add them to your PowerShell profile file so they’re created automatically at every session start.
# Open your profile for editing
notepad $PROFILE
# Add these lines to your profile:
# Set-Alias -Name np -Value notepad
# Set-Alias -Name gs -Value Get-Service
# function ll { Get-ChildItem -Force @args }
# function touch { New-Item -ItemType File -Name $args[0] }
After saving, the aliases will be available in every new PowerShell session automatically.
Common Errors and Fixes
- Aliases cannot include arguments: This is the most common confusion with PowerShell aliases.
Set-Alias myls "Get-ChildItem -la"will create an alias that points to the literal string"Get-ChildItem -la"as a command name, which fails at runtime. The solution is always a function:function myls { Get-ChildItem -Force $args }— functions fully support arguments. - Session-only unless added to profile: If your custom aliases disappear when you close and reopen PowerShell, you forgot to add them to your
$PROFILEfile. Anything created interactively only persists for that session. Profile location: run$PROFILEto see the path, then open it withnotepad $PROFILEand add your alias definitions.
Related Cmdlets / See Also
Wrapping Up
Aliases save keystrokes for the commands you run most often, and function wrappers extend that to shortcuts with built-in default arguments. As a next step, open your profile with notepad $PROFILE and add five aliases or function shortcuts for the cmdlets you use every day — you’ll notice the improvement immediately.


