Get-Alias and its reverse


New Member
Powershell provides the inaptly-named commandlet Get-Alias, thus:

[1][13]>get-alias gci
CommandType Name Definition
----------- ---- ----------
Alias gci Get-ChildItem

I say inaptly because it's not getting you the alias, you're giving it the alias. And if you have the alias gci, say, to begin with, you probably already know that it means Get-Childitem, so Get-Alias doesn't tell you anything you didn't already know.
On the other hand, you the user, Powershell Community Extensions, Powershell itself, et. al., add more aliases than you can shake a stick at, so I often want to go in the other direction.
Here is a triviality I have found useful enough to put in my profile. ("fal" stands for find alias.)

filter global:fal
get-alias | where-object { [string]$comparestring=($_.Definition)
$comparestring-eq"$first") } | Sort-Object-property Definition | Format-Table-Autosize

For example:

[1][12]>fal get-childitem
CommandType Name Definition
----------- ---- ----------
Alias dir Get-ChildItem
Alias ls Get-ChildItem
Alias gci Get-ChildItem

More useful than Get-Alias IMHO, but YMMV. ;)

My Computer