Finding Aliases for PowerShell Cmdlet Parameters

Many PowerShell cmdlet parameters have aliases such as Cn for ComputerName. These aliases aren't well documented and even viewing the full help for a cmdlet doesn't show them. The following command can be used to display a list of all the parameters for a particular PowerShell cmdlet and any aliases that exist for those parameters:

1(Get-Command (Read-Host "Enter a PowerShell Cmdlet Name")).parameters.values |
2select name, aliases

parameter-aliases1.jpg

One thing to keep in mind is this is a list of all the parameters from all parameter sets which means some of them are mutually exclusive and can't be used with one another.

If you only want to display the parameters that have aliases, add the Where-Object cmdlet to the command and test to see if aliases is true:

1(Get-Command (Read-Host "Enter a PowerShell Cmdlet Name")).parameters.values |
2where aliases | select name, aliases

parameter-aliases2.jpg

Here's a parameterized script with a mandatory parameter for the cmdlet name and an optional parameter for the parameter name:

1param (
2[Parameter(Mandatory=$True)]
3[string]$CmdletName,
4[string]$ParameterName = '*'
5)
6(Get-Command $CmdletName).parameters.values |
7where name -like $ParameterName | select name, aliases

Running the script without at least specifying the mandatory parameter will prompt for it. Specifying only a cmdlet name returns all parameters and any aliases that exist for them:

parameter-aliases3.jpg

Specifying the cmdlet and parameter name only returns that particular parameter and the aliases for it if any exist:

parameter-aliases4.jpg

Update 08/30/12

The full help in PowerShell version 3 does show parameter aliases. The aliases for a specific parameter can be viewed using Help CmdletName -Parameter ParameterName:

parameter-aliases5.jpg

µ