Windows PowerShell Get-Alias
Introduction to Windows PowerShell Get-Alias
PowerShell has a whole family of Aliases. One group of these aliases provides shorthand for the regular cmdlets; instead of typing thirteen keystrokes for Get-Childitem, just use a PowerShell alias and type the three letters: gci.
However, I am going to concentrate on the other group of Aliases, those cmdlets that are designed to help people migrate from other languages. Thanks to aliases, those who know DOS can still use dir, and those who are familiar with UNIX can still use 'ls' in PowerShell. These old commands work because PowerShell has created an internal link so that when you type dir it translates to the cmdlet Get-ChildItem.
PowerShell Alias Topics
I have a tough mission, to persuade people to abandon the DOS command-line and switch to PowerShell. There are three threads to this mission.
1) Have faith that an alias such as cd will change directory in PowerShell just as it did in DOS.
2) Realize that built-in operating system commands such as Ping, Ipconfig and Shutdown work in PowerShell 98% as well as they did with cmd.exe. Consequently, there is no need to use that DOS box, just use the PowerShell command-line instead. I understand that this is a leap of faith, and to begin with may take you out of your comfort zone.
3) The third aspect of the PowerShell alias cmdlets is how they deal with native operating system commands that need user input. For this task we can employ start-Process, or the versatile PowerShell cmdlet New-Object with its -ComObject parameter. I just want to make you aware that interactive command-line utilities, such as NetSh will work in PowerShell, however they need techniques outside the scope of this article.
In conclusion, my idea is that you will learn PowerShell faster if you use it for familiar DOS tasks. Then gradually, it will become easier and more natural to start incorporating more and more pure PowerShell commands into your working habits.
In the old days I listed PowerShell's aliases with this command:
# Research PowerShell Alias
Then I discovered that alias has its own cmdlet:
Note 1: The secret of success is employ the -Definition parameter.
Note 2: The benefit of the PowerShell Get-Alias is that you can investigate more properties by appending | Get-Member, thus:
# Research Get-Alias Properties
Note 3: Get-Help Get-Alias Now we have extra information try:
Note 4: The alias 'help' means you could try just:
Filter for built-in Aliases (They have the ReadOnly property)
#PowerShell Alias Example
Note 5: To list only the 50(ish) DOS and UNIX commands change -Match to -NotMatch
SolarWinds' Network Performance Monitor will help you discover what's happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.
What I like best is the way NPM suggests solutions to network problems. Its also has the ability to monitor the health of individual VMware virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.
More Filters for the PowerShell Alias Family
There are other ways to filter Get-Alias, for example, [a-g]* lists all the aliases beginning with letters 'a' through 'g'. Incidentally, this simple example demonstrates how PowerShell employs wildcards, and also alerts you to the significance of different types of brackets.
As ever, you can refer to help, for example type: help Get-Alias. There is also: help New-alias, or even help delete-alias. I have deliberately not emphasised creating your own aliases. My reasoning is this, any aliases you create will not work if you send scripts containing such aliases to other people. This could cause confusion and thus is best avoided especially if you are just starting to learn PowerShell.
As you check this list see if you can detect two types of PowerShell Alias cmdlets, those convenience Aliases that simply save key strokes, for example, gci (Get-Childitem) and those Aliases that help people transition from other languages, for example, cd (Set-location).