Alises, in PowerShell, are a fairly straightforward concept. You can get the full details yourself with this command:
PowerShell." You can use them for cmdlets or command elements: functions, scripts, files or executables. When you type the alias, along with any standard parameters and arguments, it will work just as expected. To create a new one simply use the New-Alias cmdlet. The simplest form takes two arguments for the -Name and -Value parameters. -Name refers to the alias you intend to use and -Value is the original cmdlet or command element you are aliasing.
There are several built-in aliases the come as a part of PowerShell straight out of the box. To get an idea of what these aliases are simply run this command:
Get-Help about_Aliases -FullIn short, Aliases "[d]escribe how to use alternate names for cmdlets and commands in Windows
PowerShell." You can use them for cmdlets or command elements: functions, scripts, files or executables. When you type the alias, along with any standard parameters and arguments, it will work just as expected. To create a new one simply use the New-Alias cmdlet. The simplest form takes two arguments for the -Name and -Value parameters. -Name refers to the alias you intend to use and -Value is the original cmdlet or command element you are aliasing.
New-Alias -Name gfs -Vale Get-FileSignatureWhen you create aliases for regular executables you no longer need to fully qualify the executable path. Simply type the alias and voila, there you have it.
There are several built-in aliases the come as a part of PowerShell straight out of the box. To get an idea of what these aliases are simply run this command:
Get-Aliaswhen it executes it will return a list like this shortened example. I had not seen this modified syntax in v3 yet. I like it:
When working with aliases themselves, there are five main cmdlets to be aware of:CommandType Name ModuleName----------- ---- ----------Alias % -> ForEach-ObjectAlias ? -> Where-ObjectAlias ac -> Add-ContentAlias asnp -> Add-PSSnapinAlias cat -> Get-ContentAlias cd -> Set-LocationAlias chdir -> Set-Location
- Get-Alias. Gets all the aliases in the current session.
- New-Alias. Creates a new alias.
- Set-Alias. Creates or changes an alias.
- Export-Alias. Exports one or more aliases to a file.
- Import-Alias. Imports an alias file into Windows PowerShell
Get-Alias p* -DetailedOne last thing to note about aliases: PowerShell has a provider for them. So, you can work with them just like any other provider. Since its a provider, I can set it and do what i need to. For example,
PS C:Userswsteele> cd alias:PS Alias:> dirCommandType Name ModuleName----------- ---- ----------Alias % -> ForEach-ObjectAlias ? -> Where-ObjectAlias ac -> Add-ContentAlias asnp -> Add-PSSnapinAlias cat -> Get-ContentAlias cd -> Set-Location
0 comments:
Post a Comment