I’ve mentioned before that I love PowerShell, but I’m still trying to commit enough Cmdlets and aliases to memory that I can be immediately productive from a Powershell prompt without having to have a browser window open to the Powershell documentation on another monitor. Several of the Cmdlets may also be referenced through one or more aliases, and it’s rather cumbersome to discover what aliases are defined for a given Cmdlet.
I stumbled onto a bit of code that will find all aliases for a given Cmdlet which I put it into a script named Find-Alias
. That will let me type the following:
PS C:\>Find-Alias Get-ChildItem CommandType Name Definition ----------- ---- ---------- Alias dir Get-ChildItem Alias gci Get-ChildItem Alias ls Get-ChildItem
Here is the script code:
param( [Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipeLineByPropertyName=$true)] [string]$Command) Process { get-alias | where-object {$_.Definition -match $Command} }