alias powershell code example

Example 1: create alias in powershell permanently

// create a profile.ps1 file to set aliases
notepad $((Split-Path $profile -Parent) + "\profile.ps1")

// example aliases (opens notepad when you type `edit` in console)
Set-Alias edit notepad.exe

// example aliases (opens notepad when you type `edit` in console)
Set-Alias edit1 "C:\Program Files\Windows NT\Accessories\wordpad.exe"

Example 2: set alias in powershell

PS> Set-Alias -Name list -Value Get-ChildItem

PS> Get-Alias -Name list

CommandType     Name
-----------     ----
Alias           list -> Get-ChildItem

Example 3: powershell get aliases

# to get list of all aliases
Get-Alias
# or use its alias
gal

# to get a specific alias
gal 
# for example
gal man

Example 4: powershell alias setting

set-theme [some themes]

Tags:

Misc Example