Skip to content

Include module name and aliased command in suggestions from the PSCommandNotFoundSuggestion  #17768

Open

Description

Summary of the new feature / enhancement

As a user, when I mistype a cmdlet or native command, I want to be able to see suggestions descriptive name and the modules they come from in order to more clearly understand suggestions to help me succeed.

When I mistype a particular command and am returned suggestions, it is unclear what the aliased cmds do and if they are actually related to what I am trying to do or not. For example, when I type gitt I get the following suggestions:

PS C:\Users\stevenbucher> gitt
gitt: The term 'gitt' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Suggestion [4,General]: The most similar commands are: gi, gin, gtz, It, imt.

It is not clear exactly what these aliased commands are and thus I have to investigate further, I have to do Get-Command <cmd> to learn more. This is good but it would be more helpful if this was given to me right after my initial error.

Another example can be when I may type something like

PS C:\Users\stevenbucher> Get-PSResurce
Get-PSResurce: The term 'Get-PSResurce' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Suggestion [4,General]: The most similar commands are: Get-PSResource, Get-AzResource, Get-DscResource, Set-AzResource, Get-PSSession, Get-Service.

It would be helpful to know which modules each of these suggestions came from. Similar to what bash does

stevenbucher@StevenBucherPC:~$ sudi

Command 'sudi' not found, did you mean:

  command 'sudo' from deb sudo (1.8.31-1ubuntu1.2)
  command 'sudo' from deb sudo-ldap (1.8.31-1ubuntu1.2)

Try: sudo apt install <deb name>

I would love to hear other's thoughts on this feature! Thanks!

Proposed technical implementation details (optional)

Have more detailed suggestions for when suggestions are given. See examples below:

PS C:\Users\stevenbucher> gitt
gitt: The term 'gitt' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Suggestion:
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           gi -> Get-Item
Alias           gin -> Get-ComputerInfo                            7.0.0.0    Microsoft.PowerShell.Management
Alias           gtz -> Get-TimeZone                                7.0.0.0    Microsoft.PowerShell.Management
Function        It                                                 5.3.3      Pester
Alias           imt -> Invoke-PSMDTemplate                         2.2.11.139 PSModuleDevelopment
PS C:\Users\stevenbucher> Get-PSresurce
Get-PSresurce: The term 'Get-PSresurce' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Suggestion: 
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-PSResource                                     3.0.12     PowerShellGet
Cmdlet          Get-AzResource                                     6.0.1      Az.Resources
Function        Get-DscResource                                    1.1        PSDesiredStateConfiguration
Cmdlet          Set-AzResource                                     6.0.1      Az.Resources
Function        Get-PSFFeature                                     1.7.237    PSFramework
Function        Get-PSFMessage                                     1.7.237    PSFramework

Activity

  1. jhoneill commented on Jul 26, 2022

    @jhoneill

    The first example shows that the process is not checking for external programs, which is something which should also be addressed.

    This is an experimental feature which some people may prefer to leave disabled - in the case of simple typing errors we (probably) know we mean "git" or "Get-PSResource" - some people may want the current one line version and some may want the full details. So this should be an option and so should the one line version. (since the feature is still experimental, the default can be discussed) .

    At present the alias is an issue. I know that fl / ft / fw are format-List / Table / Wide and I know there is a format-hex command so I try this

     type .\deleteme.txt | fh
    fh: The term 'fh' is not recognized as a name of a cmdlet, function, script file, or executable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    
    Suggestion [4,General]: The most similar commands are: fl, ft, fw, oh, fc, fhx, F:, h.
    

    h might be the alias, so might oh , fc doesn't look likely and I can eliminate fl/ft/fw and f: but nothing is making fhx jump out and I might need to spend longer looking at the list thing "It OH for out-hex ? no that's Out-host H for Hex ? No that's history " and so on

    Some aliases don't have their source (fc / fl / ft for example) and some don't show where they go until the module is loaded (fimo for example):

    PS>  get-command -type Alias -Name f*
    
    CommandType     Name                                               Version    Source
    -----------     ----                                               -------    ------
    Alias           fc -> Format-Custom
    Alias           fhx -> Format-Hex                                  7.0.0.0    Microsoft.PowerShell.Utility
    Alias           fimo ->                                            2.2.5      PowerShellGet
    Alias           fimo ->                                            2.2.5      PowerShellGet
    Alias           fimo ->                                            1.0.0.1    PowerShellGet
    Alias           Find-SeElement                                     3.0.1      Selenium
    Alias           fl -> Format-List
    

    Since I mention fimo , fm doesn't find it

    PS>  fm
    fm: The term 'fm' is not recognized as a name of a cmdlet, function, script file, or executable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    
    Suggestion [4,General]: The most similar commands are: fl, ft, fw, gm, rm, fc, F:, %, ?, cp.
    

    Like fh it would help the search if the logic says F & H or F & M might be the first letters of the full command
    so if we find an alias for something where the canonical name is f*-h* or f*-m* those are good matches. It's not likely that I want % ? or cp when I typed fm.

    So there is work to do before this feature comes out of experimental status.

  2. microsoft-github-policy-service commented on Nov 15, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  3. soredake commented on Nov 19, 2023

    @soredake

    Still wanted.

  4. microsoft-github-policy-service commented on Nov 26, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

  5. microsoft-github-policy-service commented on Nov 26, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions