Getting aliases
In this recipe, we look at aliases in PowerShell.
How to do it...
Let's check out aliases in PowerShell.
Open PowerShell ISE. Go to Start | Accessories | Windows PowerShell | Windows PowerShell ISE.
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"
How it works...
The Get-Alias
cmdlet returns all PowerShell aliases. PowerShell's building blocks are cmdlets, and 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 Unix environment. Aliases allow most well-known commands to be run from within PowerShell. To list all aliases, use the following:
#list all...