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

Robin Kretzschmar @darksmile92

About: Started coding at the age of 13, now a professional software engineer and Scrum Master, creating and maintaining enterprise solutions. Eat - Sleep - Code - Lift - Repeat 💪🏾

Location:
Mannheim, Germany
Joined:
Nov 14, 2017

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

Publish Date: May 14 '20
16 5

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.

Comments 5 total

  • Duane
    DuaneJul 11, 2020

    Great article, concise.

  • frama86
    frama86Sep 2, 2020

    Thanks, it worked like a charm!

  • SamanOvais
    SamanOvaisOct 30, 2020

    i know it should have worked but the installation policy is still untrusted🤦‍♀️ any suggestions

    • Robin Kretzschmar
      Robin KretzschmarOct 30, 2020

      try running Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted first without and then again with elevated privileges (admin)

  • vinay ayinapurapu
    vinay ayinapurapuJun 14, 2022

    this helped me today after lot of juggling with other steps. Thank you so much..

Add comment