Create An Alias With PowerShell

In this Friday post, I will show you how to create and use aliases in PowerShell and make your life a bit easier when dealing with repeatable cmdlets.

Alias

You probably don’t know it but many of the cmdlets that you are using With PowerShell are actually Aliases. The reason PowerShell is using Aliases is to short the cmdlets. Let’s take for example the cls cmdlet, this cmdlet clear the screen. cls is an alias of the clear-host. go ahead and check it using the following cmdlet.

Get-Alias cls

To view all the PowerShell aliases on PowerShell 7, type the following cmdlet, and you will be surprised how many cmdlets are aliases.

get-alias

Create Alias

To create an alias use the following cmdlet, in my case when I type time I will get the time and date which will be an alias to the get-date cmdlet.

Set-Alias time get-date

To remove an alias, use the following cmdlet.

remove-alias time

Processing…
Success! You're on the list.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.