Powershell: Not all aliases are displayed with Get-Alias

Created on 31 Aug 2020  路  4Comments  路  Source: PowerShell/PowerShell

Get-Alias should be able to provide the cmdlet name for all aliases.

Steps to reproduce

alias alias

alias unique

Expected behavior

alias alias
# Output:  alias -> Get-Alias

alias unique
# Output:  unique -> Get-Unique

Actual behavior

Get-Alias alias
Get-Alias: This command cannot find a matching alias because an alias with the name 'alias' does not exist.

Get-Alias unique
Get-Alias: This command cannot find a matching alias because an alias with the name 'unique' does not exist.

Environment data

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue-Question Resolution-Answered

Most helpful comment

All 4 comments

Those aren't real aliases; PowerShell automatically prepends Get- when commands don't resolve immediately:

https://github.com/PowerShell/PowerShell/blob/f4382202ae4622bf26795e29a7b39b9d7cdfb3fb/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1#L85-L87

Unlike actual aliases, this logic isn't represented by an object or an entry in a table, it's just something PowerShell does

Basically if Get-Alias returned these implicit aliases, you'd see an alias for every command beginning with Get- when you ran Get-Alias

Thank you! That is actually really cool. Although I do wish either Get-Alias or Get-Command would display some information about what was happening.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

garegin16 picture garegin16  路  3Comments

JohnLBevan picture JohnLBevan  路  3Comments

andschwa picture andschwa  路  3Comments

rkeithhill picture rkeithhill  路  3Comments

concentrateddon picture concentrateddon  路  3Comments