Summary: See how to determine the distribution of Windows PowerShell cmdlet aliases by length.
How many Windows PowerShell aliases are 1-letter or 2-letters or 3-letters in length? In fact, how do you determine what the entire distribution of cmdlet alias lengths is?
Use the Get-Alias cmdlet to retrieve all of the aliases. Then pipe the aliases to the Foreach-Object cmdlet and convert them to strings and retrieve the length property.
After you have done that, pipe the results to the Group cmdlet and sort by the name property (which will be the actual length of the alias.
Get-Alias | % {$_.tostring().length} | group -NoElement | sort name -Descending
0 comments