The documentation for declaring aliases in PowerShell cmdlets shows the following:
Function Get-SomeValue {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0)]
[Alias("MachineName")]
[string[]]$ComputerName
)
Get-WmiObject -Class Win32_ComputerSystem -ComputerName $ComputerName
}
What syntax do I use to create multiple aliases?
[Alias("one","two","three)][Alias("one")][Alias("two")][Alias("three")]P.S. When using Get-Help, where are the aliases supposed to be shown? So far I don't see them.
[Alias("one")][Alias("two")] and [Alias("one", "two")] both work. You see the aliases when you display the help for the parameter:
PS C:\> Get-Help Get-SomeValue -Parameter computername
-ComputerName <string[]>
Required? true
Position? 0
Accept pipeline input? true (ByValue)
Parameter set name (All)
Aliases one, two
Dynamic? false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With