PowerShell error when accessing PowerShell gallery
Most often installing PowerCLI is no problem. Sometimes there is a PowerShell error when accessing PowerShell gallery. Like now: Just wanted to install PowerCLI onto a new Windows 10. When running the command find-module vmware*
I get this error(s):
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/
?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet
connection.
Install-PackageProvider : No match was found for the specified search criteria
for the provider 'NuGet'. The package provider requires 'PackageManagement' and
'Provider' tags. Please check if the specified package has the tags.
In C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7468 Zeichen:21
+ ... $null = PackageManagement\Install-PackageProvider -Name $script:N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-Pac
kageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackagePro
vider
Fortunately I found a solution quickly here. Problem is related to security protocols used in PowerShell. Check current protocols by running:
[Net.ServicePointManager]::SecurityProtocol
My Windows 10 showed this
Ss13, Tls
To solve the problem, simply set protocol TSL version 1.2 by running
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
After this, I could install PowerCLI without any problems.
Notes
- If NuGet is already installed, you can get the error
WARNUNG: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
When runningfind-module
. The source of this is also the security protocol configuration. My post here describes a different problem.