|
Guy recommends : View the effective permissions for a folder or shared drive. Free download try it now! |
Windows PowerShell Get-AliasIntroduction to Windows PowerShell Get-AliasPowerShell 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 alias cmdlets which 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
♣ A Mission For PowerShell Aliases - Abandon DOSI 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. This week 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. Check Out PowerShell's Get-AliasIn the old days I listed PowerShell's aliases with this command: # Research PowerShell Alias Then I discovered that alias has its own cmdlet: Get-Alias Note 1: The secret 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 (Or use the alias 'help' and
try plain: 'help Get-Alias'). Now we have extra information try: Filter for only built-In Aliases (They have the ReadOnly property) #PowerShell Alias Example Note 4: To list only the DOS and UNIX commands change -Match to -NotMatch
Guy
Recommends: Free WMI Monitor for PowerShell
|