PowerShell Function to Find Parameter Aliases

While sitting through Jeff Hicks' Advanced PowerShell Scripting Workshop at PowerShell on the River in Chattanooga today, he mentioned there being a "Cn" alias for the ComputerName parameter of commands in PowerShell.

I've previously written a one-liner to find parameter aliases and at one time Microsoft had starting adding parameter aliases to the help for commands as referenced in that same blog article, but it appears that they've discontinued adding them to the help and removed the ones they previously added to it.

I thought I would polish the one-liner I had posted back in 2012 in the previously referenced blog article and turn it into a PowerShell function as shown in the following example.

 1#Requires -Version 3.0
 2function Find-MrParameterAlias {
 3    [CmdletBinding()]
 4    param (
 5        [Parameter(Mandatory)]
 6        [string]$CmdletName,
 7
 8        [ValidateNotNullOrEmpty()]
 9        [string]$ParameterName = '*'
10    )
11
12    (Get-Command -Name $CmdletName).parameters.values |
13    Where-Object Name -like $ParameterName |
14    Select-Object -Property Name, Aliases
15}

find-param-alias1b.jpg

The Find-MrParameterAlias function shown in this blog article can be found in my PowerShell repository on GitHub.

µ