PowerShell disabled support for TLS 1.0 for the Gallery - Update-Module and Install-Module broken

darksmile92

Robin Kretzschmar

Posted on May 14, 2020

PowerShell disabled support for TLS 1.0 for the Gallery - Update-Module and Install-Module broken

Microsoft announced that the PowerShell Gallery has deprecated Transport Layer Security (TLS) versions 1.0 and 1.1 as of April 2020

To provide the best-in-class encryption to our customers

Announcement, details and reasons can be found on DevBlogs.microsoft.

Awesome news!
... leaving Update-Module and Install-Module broken!

Running Update-Module or Install-Module will now throw an error like one of the two following:
Error unable to find repository

PowerShell Gallery currently unavailable

Get-PSGalleryApiAvailability : PowerShell Gallery is currently unavailable. Please try again later.
........... (cutted)
Enter fullscreen mode Exit fullscreen mode
PackageManagement\Install-Package : Unable to find repository 'https://www.powershellgallery.com/api/v2'. Use Get-PSRepository to see all available repositories.
........... (cutted)
Enter fullscreen mode Exit fullscreen mode

Fixing it (Microsoft way)

You just got the error and didn't try any wild ideas to fix it and poked around? Good, execute the migration command Microsoft provided in their announcement and you'll be good to go:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 
Install-Module PowerShellGet -RequiredVersion 2.2.4 -SkipPublisherCheck
Enter fullscreen mode Exit fullscreen mode

This will change the security protocol to TLS 1.2.

Already messed around? Fix it with this

If you already messed around with various commands like trying a proxy, removing the repository of PSGallery and stuff or getting the second error, you can fix it with the following commands:

Impatient, in a hurry or not interested in details

No judgement here.
Just looking for the commands? Quick summary:

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Register-PSRepository -Default -Verbose
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Enter fullscreen mode Exit fullscreen mode

Commands with explanations

Set the TLS 1.2 protocol first:

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Enter fullscreen mode Exit fullscreen mode

Now register the PSGallery again:

Register-PSRepository -Default -Verbose
Enter fullscreen mode Exit fullscreen mode

Check the success with Get-PSRepository and you should see an output like this:

PS C:\windows\system32> Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2
Enter fullscreen mode Exit fullscreen mode

Set the Installation Policy of PSGallery to Trusted:

Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Enter fullscreen mode Exit fullscreen mode

Result:

PS C:\windows\system32> Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Trusted              https://www.powershellgallery.com/api/v2
Enter fullscreen mode Exit fullscreen mode

Now you'll be able to run Update-Module and Install-Module successful again.

💖 💪 🙅 🚩
darksmile92
Robin Kretzschmar

Posted on May 14, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related