PSResourceGet: PowerShellGet won't search my (artifactory) repository for modules

Steps to reproduce

# get-psrepository                                                                                                      
Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2
BlahBlahPSModules         Trusted              https://artifactory.blahblah.com/api/nuget/psmodules-local

# find-module -Credential $cr1 -verbose -Name 'notreallyanamethatwillbefound'                                           VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='notreallyanamethatwillbefound'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'notreallyanamethatwillbefound'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://artifactory.blahblah.com/api/nuget/psmodules-local' and PackageManagementProvider is 'NuGet'.
WARNING: Unable to resolve package source 'https://artifactory.blahblah.com/api/nuget/psmodules-local'.
VERBOSE: Total package yield:'0' for the specified package 'notreallyanamethatwillbefound'.
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'notreallyanamethatwillbefound'. Try Get-PSRepository to see all available registered module repositories.
At C:\Users\my.name\Documents\PowerShell\Modules\PowerShellGet\2.2.1\PSModule.psm1:8871 char:9
+         PackageManagement\Find-Package @PSBoundParameters | Microsoft ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.PowerShel\u2026Cmdlets.FindPackage:FindPackage) [Find-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage

Expected behavior

My custom repository will be searched for the requested module. It is important to note that according to the Artifactory log, no requests are ever made to the server.

Actual behavior

My custom repository isn’t searched for the requested module (because the package source couldn’t be resolved, whatever that means).

Environment data

# $psversiontable                                                                                                       
Name                           Value
----                           -----
PSVersion                      6.2.2
PSEdition                      Core
GitCommitId                    6.2.2
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
#  Get-Module -ListAvailable PowerShellGet,PackageManagement                                                            

    Directory: C:\Users\my.name\Documents\PowerShell\Modules

ModuleType Version    Name                                PSEdition ExportedCommands
---------- -------    ----                                --------- ----------------
Script     1.4.4      PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, G…
Script     2.2.1      PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-Module, Find…

    Directory: C:\program files\powershell\6\Modules

ModuleType Version    Name                                PSEdition ExportedCommands
---------- -------    ----                                --------- ----------------
Script     1.3.2      PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, G…
Script     2.1.3      PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-Module, Find…
# Get-PackageProvider -ListAvailable                                                                                    
Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, …
PowerShellGet            2.2.1.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, In…
PowerShellGet            2.1.3.0

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 18 (4 by maintainers)

Most upvoted comments

I had a similar situation with a ProGet instance requiring an authentication (surprisingly it works fine without the authentication). Here is a workaround that may just work:

  • First, register the source with Register-PackageSource but specifying to use the NuGet provider (this bit is the important part)

    Register-PackageSource -Name MySource -Location “https://example.org/nuget/PSModules/” -ProviderName NuGet

  • Second, register the source with Register-PSRepository

    Register-PSRepository -Name MySource -SourceLocation “https://example.org/nuget/PSModules/

  • Third, use either Find-Package or Find-Module to locate the packages

    Find-Package -PackageManagementProvider PowerShellGet -Source MySource -Name MyModule Find-Module -Repository MySource -Name MyModule

As usual, specify proxy or credentials if needed (but most likely for all of the above commands if at all).

Let me know if it solved your issue

Cheers

This will no longer be an issue with the release of 3.0.13-beta.

@alerickson It’s primarily Artifactory where I’m at. We’re moving off a file share backed repo.

@alerickson I was able to find a work around from another issue in another project. You must register the package source with Register-PackageSource -SkipValidate prior to registering the PS repository for the process to work. After that I can work with the Artifactory repo without issue. Something about the validation process seems broken but I have no idea how to verify that.

I’m encountering this same issue for a local user, no OAuth or SAML is used on the Artifactory instance. I see the error Unable to resolve package source but I can access the URL with no issues using Invoke-WebRequest.

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.0-rc.2
PSEdition                      Core
GitCommitId                    7.0.0-rc.2
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Get-Module -ListAvailable PowerShellGet,PackageManagement


    Directory: C:\program files\powershell\7-preview\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.4.6                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     2.2.3                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.4.2                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Binary     1.0.0.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     2.1.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…
Script     1.0.0.1               PowerShellGet                       Desk      {Install-Module, Find-Module, Save-Modu…
Get-PackageProvider -ListAvailable

Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, …
PowerShellGet            2.2.3.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, In…
PowerShellGet            2.1.5.0
PowerShellGet            1.0.0.1

I’m experiencing the same error.

I’m on powershell 7 preview with PowerShellGet 2.2.3

I also have wireshark installed and I can confirm that when Find-Module returns a warning that it can’t resolve the package source, it has never tried to connect to the server.

C:\
> find-module -Repository artifactory -verbose
VERBOSE: Repository details, Name = 'artifactory', Location = 'https://artifactory.test/artifactory/api/nuget/nuget-local'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'artifactory'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://artifactory.test/artifactory/api/nuget/nuget-local' and PackageManagementProvider is 'NuGet'.
VERBOSE: Total package yield:'0' for the specified package ''.
WARNING: Unable to resolve package source 'https://artifactory.test/artifactory/api/nuget/nuget-local'.
VERBOSE: Total package yield:'0' for the specified package ''.
C:\
>

The nuget repo on this instance is configured for anonymous access, and I’v tried running Find-Module passing the -Credential parameter as well using a local Artifactory user and API key, but in all cases, the behavior is that same, which is that the Artifactory server is never actually contacted before the module declares the package source cannot be resolved.