Home » PowerShell » PowerShell: Fix – Unable to Resolve Package Source

PowerShell: Fix – Unable to Resolve Package Source

In PowerShell to fix the error “Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’, update the PowerShell client to use the TLS1.2 version.

PowerShell Unable to resole package source
PowerShell Unable to resolve package source

While trying to find the module on the PowerShell gallery using the PowerShell terminal, Find-Module PSWIndowsUpdate , if it throws an exception as given below, it may be because of the old version of the TLS version.

WARNING: Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’.
PackageManagement\Find-Package : No match was found for the specified search criteria and module name ‘PSWindowsUpdate’. 
Try Get-PSRepository to see all available registered module repositories.

At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1397 char:3
+ PackageManagement\Find-Package @PSBoundParameters | Microsoft …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power…ets.FindPackage:FindPackage) [Find-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage

In this article, we will discuss how to fix the Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’ error in PowerShell.

Solve – Unable to Resolve Package Source

If the Windows operating system is using the legacy or old TLS version, it may raise an exception while trying to find the module on PowerShell Gallary.

To find the module on the PowerShell gallery or download it, requires an updated version of TLS. Use the following PowerShell script to check the security protocol.

[Net.ServicePointManager]::SecurityProtocol

The above PowerShell script will return the TLS version.

In PowerShell to fix the Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’, update the security protocol to use the updated version of Tls.

Run the below PowerShell script to set Tls1.2 as the security protocol.

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

The above PowerShell script set the TLS1.2 version using the [Net.SecurityProtocolType]::Tls12

If you try to run the command, Find-Module PSWindowsUpdate , it will return the results as given below

PowerShell Fix- Use Tls12 to solve Unable to resolve package source
PowerShell Fix- Use Tls12 to solve Unable to resolve the package source

Conclusion

I hope the above article on how to solve the Unable to resolve package source error while trying to find the module or download the module from the PowerShell gallery is helpful to you.

An old version of TLS 1.0 and TLS1.1 has been depreciated, hence if the Windows OS is using the legacy old version, they need to update to TLS1.2 or a higher version.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.