PowerShell / PowerShell/PSResourceGet

Get-PSResource searching module folders

Open
#1,012 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Area-GetPSResource
Dominant language
C#
Stars
576
Forks
114
Avg merge
1d 2h
Merged PRs (30d)
7

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.
Steps to reproduce

If you run Get-PSResource you'll notice that its appears to be searching in the module directories instead of $env:PSModulePath. You can especially see this behavior when searching for an explicit module.

It should only be searching like this:

  1. Loop through PSModulePath
  2. If name is specified limit search to directories with that name
  3. If version number is found look one folder deeper for module manifest
Get-PSResource -Name PowerShellGet
Expected behavior
Only required folders are searched when getting resources.
Actual behavior
PS C:\> Get-PSResource -Name PowerShellGet-Verbose
VERBOSE: Retrieving directories in the path 'C:\Users\Thomas\Documents\PowerShell\Modules'
VERBOSE: Retrieving directories in the path 'C:\Users\Thomas\Documents\PowerShell\Scripts'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\AnyPackage'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\AnyPackage.Chocolatey'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\AnyPackage.PowerShellGet'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\AnyPackage.Scoop'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\AnyPackage.WinGet'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\ClassExplorer'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Cobalt'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\CompletionPredictor'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\DirectoryPredictor'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\EditorServicesCommandSuite'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Foil'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\InvokeBuild'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\kbupdate'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\kbupdate-library'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Microsoft.PowerShell.Archive'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Microsoft.PowerShell.ConsoleGuiTools'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Microsoft.PowerShell.Crescendo'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Microsoft.PowerShell.GraphicalTools'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Microsoft.PowerShell.SecretManagement'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Microsoft.PowerShell.SecretStore'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Microsoft.PowerShell.TextUtility'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\NewFile'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\PackageManagement'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Pester'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Plaster'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\platyPS'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerGit'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGetCompat'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\PSCodeHealth'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\PSDesiredStateConfiguration'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\PSFramework'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\PSReadLine'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\PSScriptAnalyzer'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\PSSQLite'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\PSStringTemplate'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\Scoop'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\ScriptLog'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\SNMP'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\SqlServer'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\TabExpansionPlusPlus'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\UniversalPackageManager.PowerShellGet'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Modules\UniversalPackageManager.Provider.Msu'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Scripts\Export-PSObjectToINI.ps1'
VERBOSE: All paths to search: 'C:\Users\Thomas\Documents\PowerShell\Scripts\Get-WindowsAutoPilotInfo.ps1'
VERBOSE: Entering GetPSResource
VERBOSE: Searching through package path: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet'
VERBOSE: Searching through package path: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet'
VERBOSE: Searching through package version path: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\3.0.19'
VERBOSE: Package version parsed as NuGet version: '3.0.19-beta19'
VERBOSE: Reading package metadata from: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\3.0.19\PSGetModuleInfo.xml'

VERBOSE: Searching through package version path: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\3.0.17'
VERBOSE: Package version parsed as NuGet version: '3.0.17-beta17'
VERBOSE: Reading package metadata from: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\3.0.17\PSGetModuleInfo.xml'
VERBOSE: Searching through package version path: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\3.0.16'
VERBOSE: Package version parsed as NuGet version: '3.0.16-beta16'
VERBOSE: Reading package metadata from: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\3.0.16\PSGetModuleInfo.xml'
VERBOSE: Searching through package version path: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\3.0.14'
VERBOSE: Package version parsed as NuGet version: '3.0.14-beta14'
VERBOSE: Reading package metadata from: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\3.0.14\PSGetModuleInfo.xml'
VERBOSE: Searching through package version path: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\3.0.12'
VERBOSE: The PSGetModuleInfo.xml file found at location: C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\3.0.12\PSGetModuleInfo.xml cannot be parsed due to TryReadPSGetInfo: Cannot read the PowerShellGet information file with error: Could not find file 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\3.0.12\PSGetModuleInfo.xml'.
VERBOSE: Searching through package version path: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\2.2.5'
VERBOSE: Package version parsed as NuGet version: '2.2.5.0'
VERBOSE: Reading package metadata from: 'C:\Users\Thomas\Documents\PowerShell\Modules\PowerShellGet\2.2.5\PSGetModuleInfo.xml'
Error details

No response

Environment data
Name          Version
----          -------
PowerShellGet 3.0.19

Name                           Value
----                           -----
PSVersion                      7.4.0-preview.2
PSEdition                      Core
GitCommitId                    7.4.0-preview.2
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visuals

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing Get-PSResource -Name PowerShellGet and reviewing the Get-PSResource search entry point. Trace how $env:PSModulePath becomes the search paths, then add or update coverage for the reported behavior; done means an explicit module search only checks the required module directories and version subfolders.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.