Categories
Microsoft PowerShell

Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’

I was running a command to install a PowerShell module, e.g.

Install-Module -Name navcontainerhelper -Force

while I received the following error message:

Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’

Solution:

Run PowerShell as Administrator and run the following command to force to use TLS1.2 protocol

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Did my solution solve your problem? Leave a reply.

89 replies on “Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’”

This was exactly what I needed, thanks so much!!! The answer was so straightforward I wasn’t really sure this has much “substance” (no offense intended) but the solution really was that precise and effective, so thank you very much for posting this!! Cheers

Hi Chris,

I’m happy that I was able to help you through my website. Yes, my goal is to provide a working solution to the error messages I received in my daily experience working in IT.
Your message is really appreciated because give me the motivation to continue writiing new posts.

Thank you

Not solve for me.

I receive the erro when execute the command ” invoke-command -ComputerName $computer -ScriptBlock {install-module pswindowsupdate -force}” and setting the $computer to the local hostname, but if i run “install-module pswindowsupdate -force” directly I dont receive the error.

Hi,

Actually I had an issue with an integration in NAV that suddenly stopped working and the solution was to enable use TLS 1.2
I applied the same solution here and it worked.

Thank you, vey much!

This was my case:

Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\Windows\system32> Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClo
bber
WARNING: Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’.
PackageManagement\Install-Package : No match was found for the specified search criteria and module name
‘PackageManagement’. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
+ … $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power….InstallPackage:InstallPackage) [Install-Package], Ex
ception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

PS C:\Windows\system32> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
PS C:\Windows\system32> Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClo
bber
PS C:\Windows\system32>

Fantastic. Have been dealing with this problem for months and your one-liner solved it. Thanks so much!

Thank you very much, this is very helpful.. But I noticed the authentication prompt doesn’t come with all clients, Mobile client fine, Apple devices fine, but windows 10 sometime it gives the authentication prompt sometime it doesn’t.. Is there an additional settings that need to be done on the Access Point Itself..?

Much appreciated your help and support.

Regards

Thanks i wasn’t able to install any module from the gallery , this resolved my issue.

This works but only for the session. A permanent solution is to run the following in a admin PS session then restart PS.
# set strong cryptography on 64 bit .Net Framework (version 4 and above)
Set-ItemProperty -Path ‘HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319’ -Name ‘SchUseStrongCrypto’ -Value ‘1’ -Type DWord

# set strong cryptography on 32 bit .Net Framework (version 4 and above)
Set-ItemProperty -Path ‘HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319’ -Name ‘SchUseStrongCrypto’ -Value ‘1’ -Type DWord

I used the SchUseStrongCrypto solution to get past the error: Unable to download from URI ‘https://go.microsoft.com/fwlink/?…

After a system restart, I then got the error: Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’

I tried the [Net.ServicePointManager]::SecurityProtocol = … solution posted here. but after entering :
Install-Module PowershellGet -Force , I got the same error!

In desperation I entered Install-Module PowershellGet -Force -AllowClobber
and it worked!

Golden! Thank you so much for this, and also – thanks previous commenters for pushing this to the top of Google results for my query.. 🙂
I wonder if the culprit is me (@work) still being on Win7?

How refreshing to encounter a concise description and accurate answer to the problem. I didn’t have to watch a 5-minute video, nor read about how you forgot to feed your cat because you were working so diligently to figure out the problem. Thanks for sharing your expertise.

it did solve two problems and i should have known. 🙂 first i could not send mail via SSL and sendgrid.
thought it was the code i had written, so tried to download a module. got the error. fixed it and presto. So, thanks!!

Thanks a lot for the simple and to the point solution @Eclipses!
And funny to encounter a former colleague struggling with the same problem 🙂
Greetings,
Gaspar

Thanks for the response. I didn’t know it was down, I guess bad timing on my part. Oh well, I’ll try another day.

This has been working until recently – suddenly the problem is back, despite settings

The specified Uri ‘https://www.powershellgallery.com/api/v2/’ for parameter ‘SourceLocation’ is an invalid Web Uri.

PS C:\WINDOWS\system32> [Net.ServicePointManager]::SecurityProtocol
Tls12

Registry keys also set.

Any suggestion welcome.
I can access the psgallery from a web browser but not doing web-request from powershell

Thank you for your valuable contribution, I’m sure this information will help others as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.