In this recipe, we take a look at aliases in PowerShell.
Let's check out aliases in PowerShell:
Open PowerShell ISE as an administrator.
Add the following script and run it:
#list all aliases Get-Alias #get members of Get-Alias Get-Alias | Get-Member #list cmdlet that is aliased as dir $alias:dir #list cmdlet that is aliased as ls $alias:ls #get all aliases of Get-ChildItem Get-Alias -Definition "Get-ChildItem"
An alias in PowerShell is a different name that you can use for a cmdlet. Some cmdlets already come with a handful of aliases, but you can create your own aliases for cmdlets as well.
The Get-Alias
returns all PowerShell aliases. PowerShell's building blocks are cmdlets that are named using the <Verb-Noun>
convention. For example, to list contents of a directory, we use Get-ChildItem
. There are, however, better-known ways to get this information such as dir
if running the Windows Command Prompt and ls
if running in a Nix environment...