GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 'Get-Module <Path-to-directory> -ListAvailable -All' should return all modules within the directory · Issue #7160 · PowerShell/PowerShell

'Get-Module <Path-to-directory> -ListAvailable -All' should return all modules within the directory #7160

New issue
Copy link
New issue
Copy link
Closed
Closed
'Get-Module <Path-to-directory> -ListAvailable -All' should return all modules within the directory#7160
Copy link
Labels
Breaking-Changebreaking change that may affect usersbreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues

Description

@daxian-dbw
Dongbo Wang (daxian-dbw)
opened on Jun 25, 2018
Issue body actions

I suggest changing the current behavior of Get-Module <path-to-directory> -ListAvaialble and Get-Module <path-to-directory> -ListAvaialble.

Today, Get-Module <path-to-directory> -ListAvaialble assumes the passed in directory is a module folder -- it uses the directory name as the module name and only tries to find valid module files with the same name right under the directory. Get-Module <path-to-directory> -ListAvaialble -All does recursively search the directory for valid module files, but then it filters the found modules using the directory name, so again, only the modules with the same name as the given directory name can be returned. Both behaviors seem wrong and useless to me.

I think for Get-Module <directory-Foo> -ListAvailable and Get-Module <directory-Foo> -ListAvailable -All, the behaviors should be the same as if running Get-Module -ListAvailable and Get-Module -ListAvailable -All when $env:PSModulePath = <directory-Foo>. Namely, Get-Module <directory-Foo> -ListAvailable should treat directory-Foo as a module path, and find all availalbe default modules within that module path; Get-Module <directory-Foo> -ListAvailable -All should also treat directory-Foo as a module path, and find all modules within that module path. The proposed behaviors make more sense because:

  • The semantics of -ListAvailable and -All is consistent between Get-Module <directory-path> and Get-Module <module-name>;
  • The proposed behaviors are more useful since they allow the user to look for available modules from an arbitrary directory.

Expected Behavior

Get-Module "$PSHOME\Modules" -ListAvailable
## Return all availalbe default modules under '$PSHOME\Modules',
## just like running 'Get-Module -ListAvailable' when '$env:PSModulePath == "$PSHOME\Modules"'

Get-Module "$PSHOME\Modules" -ListAvailable -All
## Return all modules under '$PSHOME\Modules', 
## just like running 'Get-Module -ListAvailable -All' when '$env:PSModulePath == "$PSHOME\Modules"'

Actual Behavior

PS:4> Get-Module "$PSHOME\Modules" -ListAvailable
Get-Module : The specified module 'C:\Program Files\PowerShell\6.0.2\Modules' was not found. Update the Name parameter to point to a valid path, and then try again.
At line:1 char:1
+ Get-Module "$PSHOME\Modules" -ListAvailable
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (C:\Program File...l\6.0.2\Modules:String) [Get-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFoundForGetModule,Microsoft.PowerShell.Commands.GetModuleCommand

PS:5> Get-Module "$PSHOME\Modules" -ListAvailable -All
Get-Module : The specified module 'C:\Program Files\PowerShell\6.0.2\Modules' was not found. Update the Name parameter to point to a valid path, and then try again.
At line:1 char:1
+ Get-Module "$PSHOME\Modules" -ListAvailable -All
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (C:\Program File...l\6.0.2\Modules:String) [Get-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFoundForGetModule,Microsoft.PowerShell.Commands.GetModuleCommand

Activity

  1. Dongbo Wang (daxian-dbw)
    added
    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bug
    Breaking-Changebreaking change that may affect usersbreaking change that may affect users
    Area-Cmdlets-Core
    and removed
    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bug
    on Jun 25, 2018
  2. daxian-dbw commented on Jun 25, 2018

    @daxian-dbw
    Dongbo Wang (daxian-dbw)
    on Jun 25, 2018
    MemberAuthor
    More actions

    Bruce Payette (@BrucePay) Could you please take a look at the proposed behavior change and see if it makes sense?

  3. Dongbo Wang (daxian-dbw)
    added
    Review - CommitteeThe PR/Issue needs a review from the PowerShell CommitteeThe PR/Issue needs a review from the PowerShell Committee
    on Jun 27, 2018
  4. Steve Lee (SteveL-MSFT)
    added
    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bug
    Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decision
    and removed
    Review - CommitteeThe PR/Issue needs a review from the PowerShell CommitteeThe PR/Issue needs a review from the PowerShell Committee
    on Jun 27, 2018
  5. SteveL-MSFT commented on Jun 27, 2018

    @SteveL-MSFT
    Steve Lee (SteveL-MSFT)
    on Jun 27, 2018
    Member
    More actions

    @PowerShell/powershell-committee reviewed this and to get the desired behavior to list modules in a path, you must add a wildcard:

    get-module $path\* -listavailable

  6. joeyaiello commented on Jun 27, 2018

    @joeyaiello
    Joey Aiello (joeyaiello)
    on Jun 27, 2018
    Contributor
    More actions

    Hemant Mahawar (@HemantMahawar) and I were the minorities in the room, but we also felt like it would make sense (though a very low priority) to add a -Path parameter that doesn't expect that the leaf of the directory it's passed is a module name.

  7. daxian-dbw commented on Jun 28, 2018

    @daxian-dbw
    Dongbo Wang (daxian-dbw)
    on Jun 28, 2018
    MemberAuthor
    More actions

    It turns out the existing behavior of Get-Module <Path-to-directory> -ListAvailable becomes interesting when wildcard characters are using in the path. So we cannot change the current behavior.
    I will close this issue and update #7145 to revert the breaking change.

  8. Dongbo Wang (daxian-dbw)
    closed this as completedon Jun 28, 2018
  9. Ryan Yates (kilasuit)
    added
    WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
    and removed
    WG-Cmdlets-Core
    on Jul 17, 2026
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

    Breaking-Changebreaking change that may affect usersbreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.