Set Alias - PowerShell


Creates, modifies, or removes aliases. Aliases reduce the number of characters needed to run a command by creating a shorter name reference. Aliases are also helpful when commands have long names or many parameters.


Set-Alias [-Name] <String[]> [-Definition] <String[]> [-Scope] {Global | Local} [-Force] [-WhatIf] [-Confirm]


  • -Name: Specifies the name of the alias. If the alias does not exist, the command creates it. If the alias exists, the command modifies it.
  • -Definition: Specifies the command or script that the alias represents.
  • -Scope: Specifies the scope of the alias. By default, aliases have a local scope, which means they are only available in the current PowerShell session.
    • Global: Creates a global alias that is available in all PowerShell sessions.
    • Local: Creates a local alias that is only available in the current PowerShell session.
  • -Force: Overwrites an existing alias without prompting for confirmation.
  • -WhatIf: Shows what the command would do without actually performing it.
  • -Confirm: Asks for confirmation before overwriting an existing alias.


Creating an alias:

Set-Alias LL Get-ChildItem

This command creates an alias named LL that refers to the Get-ChildItem command.

Modifying an alias:

Set-Alias LL Get-Item

This command modifies the LL alias to point to the Get-Item command.

Removing an alias:

Set-Alias LL -Remove

This command removes the LL alias.

Common Issues

  • Aliases might not work in all PowerShell sessions.
    • Solution: Use the -Scope Global parameter to create global aliases.
  • Aliases might conflict with existing commands.
    • Solution: Use the -Force parameter to overwrite existing aliases.


Combine Set-Alias with other commands to create custom command shortcuts. For example:

Set-Alias MakePrompt { Set-Prompt -ForegroundColor Green -BackgroundColor Red }