What runs in PowerShell when I run the "alias" command?
Is it an alias? A function? It appears that "alias" is itself an alias to the get-alias command. Yet alias itself does not show up in the list returned by get-alias. Is it being strippe开发者_如何学运维d out?
(This is out of curiosity, I'm not planning on re-aliasing "alias" or anything crazy.)
In powershell, if a command does not immediately match something in the command search path, it will prepend it with "get-" and try again. So when you type "alias," powershell will retry with "get-alias" if the former is not matched against a command.
-Oisin
In Powershell 2, you'll get a list of defined aliases. It tells, for exemple, that gal
is an alias to get-alias
.
Running Get-Help alias | more
brings this:
PS C:\Users\Fernando> Get-Help alias | more
PROVIDER NAME Alias
DRIVES Alias:
SYNOPSIS Provides access to the Windows PowerShell aliases and the values that they represent.
DESCRIPTION The Windows PowerShell Alias provider lets you get, add, change, clear, and delete aliases in Windows PowerShell.
An alias is an alternate name for a cmdlet, function, or executable
file. Windows PowerShell includes a set of buil t-in aliases. And, you can add your own aliases to the current session and to your Windows PowerShell profile.
The Alias provider is a flat namespace that contains only the alias
objects. The aliases have no child items.
Each alias is an instance of the System.Management.Automation.AliasInfo
class.
The Alias provider exposes its data store in the Alias: drive. To
work with aliases, you can change your location t o the Alias: drive by using the following command:
set-location alias: Or, you can work from any other Windows PowerShell drive. To reference
an alias from another location, use the Alia s: drive name in the path.
Windows PowerShell includes a set of cmdlets that are designed to view
and to change aliases:
Export-Alias Get-Alias Import-Alias New-Alias Set-Alias When you use these cmdlets, you do not need to specify the Alias: drive
in the name.
The Alias provider supports all the cmdlets that have the Item noun
except for the Invoke-Item cmdlet. And, it supp orts the Get-Content and Set-Content cmdlets. The Alias provider does not support the cmdlets that have the ItemPro perty noun. And, the Alias provider does not support the Filter parameter in any cmdlet.
All changes to the aliases affect the current session only. To save the
changes, add the changes to the Windows Pow erShell profile. Or, use the Export-Alias and Import-Alias cmdlets.
精彩评论