🎓 A1Learner
🔍
0 of 52 lessons completed

PowerShell Aliases

An alias is a short nickname for a longer cmdlet name. You type the nickname, and PowerShell runs the full cmdlet.

Create an alias for Get-Date

Set-Alias creates the nickname. Read its Definition property back to check it.

Set-Alias -Name greet -Value Get-Date
(Get-Alias greet).Definition

Create an alias for Write-Output

The same pattern works for another cmdlet. Create a short nickname for Write-Output.

Set-Alias -Name say -Value Write-Output
(Get-Alias say).Definition

Run a cmdlet through its alias

An alias runs like the cmdlet it names. Run Get-Date through the greet alias.

Set-Alias -Name greet -Value Get-Date
greet -Date "2026-10-28" -Format "yyyy-MM-dd"

Example

Set-Alias -Name say -Value Write-Output
say "Hello from an alias"
(Get-Alias say).Definition

Key points

  • Alias: a short nickname for a cmdlet.
  • Set-Alias creates a new alias.
  • Get-Alias reads an alias back.
  • The Definition property holds the full cmdlet name.
  • An alias runs exactly like the cmdlet it names.

In this example, the first line creates the say alias, the second line prints a message through the alias, and the third line prints the full cmdlet name the alias stands for.

Note

On Linux, PowerShell has no ls alias by default.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

Which cmdlet creates a new alias?