Skip to content

Get-PSResource searching module folders #1012

Open
@ThomasNieto

Description

@ThomasNieto

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions