# PowerShellGallery disables support for TLS 1.0 breaking Install-Module

Troubleshoot Install-Module failures on Windows Server 2008 R2 after PowerShell Gallery disabled TLS 1.0, and learn how switching to TLS 1.2 restores module downloads.

blog

09 Apr 2020 pl

![PowerShellGallery disables support for TLS 1.0 breaking Install-Module](/wp-content/uploads/2020/04/img_5ea804caa6795.png)

[Zobacz obrazy (2)](#pf-content-image-1-0)

A few days ago, I tried to use **Install-Module** on the old **Windows 2008R2** system that I use for specific tasks.

```powershell
install-module adessentials -Scope CurrentUser -Force
```

Unfortunately, it failed with a weird message saying:

> WARNING: Source Location ‘[https://www.powershellgallery.com/api/v2/package/PSEventViewer/1.0.13](https://www.powershellgallery.com/api/v2/package/PSEventViewer/1.0.13)' is not valid. PackageManagement\Install-Package : Package ‘PSEventViewer' failed to download. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
> 
> - … $null = PackageManagement\Install-Package @PSBoundParameters
> - CategoryInfo : ResourceUnavailable: (C:\Users\adm_jz…entViewer.nupkg:String) [Install-Package], Exception
> - FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

[!\[Błąd Install-Module w PowerShell pokazujący nieprawidłową lokalizację źródła po wyłączeniu obsługi TLS 1.0 przez PowerShell Gallery.\](/wp-content/uploads/2020/04/img_5ea804caa6795.png)](/wp-content/uploads/2020/04/img_5ea804caa6795.png)

At first, I thought that **PowerShellGallery** is just blocked or broken, so I gave up retrying. However, today [Justin Grote](https://twitter.com/JustinWGrote) mentioned in a tweet that it's because **PowerShellGallery** disabled support for TLS 1.0 and is now requiring TLS 1.2. A simple change, but for older systems a breaking change. You can read about this change on [the official PowerShell Team blog](https://devblogs.microsoft.com/powershell/powershell-gallery-tls-support/).

### 💡 TLS 1.0 to TLS 1.2 workaround

If you check **SecurityProtocol** that is used by **PowerShell**, it reports **SystemDefault**.

```powershell
[Net.ServicePointManager]::SecurityProtocol
```

[!\[Wynik SecurityProtocol w PowerShell pokazujący wartość SystemDefault przed wymuszeniem TLS 1.2.\](/wp-content/uploads/2020/04/img_5e8f7dd72f162.png)](/wp-content/uploads/2020/04/img_5e8f7dd72f162.png)

But SystemDefault is different on every system. So while my up to date Windows 10 didn't notice any change, my work servers did. The error you saw above comes from TLS 1.2 requirement where servers I use are set to default TLS 1.0. The workaround for this issue is simple

```powershell
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
```

But the problem with that approach is that you need to run it every time you open a new **PowerShell** session and want to use **Install-Module**, **Update-Module**, or any other command that interacts with PowerShellGallery. In case you want to fix this permanently you could use registry entries forcing all **.NET processes targeting .NET 4.5** to use **strong crypto**.

```powershell
Set-ItemProperty `
    -Path "HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319" `
    -Name "SchUseStrongCrypto" `
    -Value "1" `
    -Type DWord `
    -Force

Set-ItemProperty `
    -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319" `
    -Name "SchUseStrongCrypto" `
    -Value "1" `
    -Type DWord `
    -Force
```

So if you're using any automated scripts that use **Install-Module** or **Update-Module** to configure things, you may want to update registry or add additional code to prevent any issues. For details you can read [Transport Layer Security (TLS) best practices with the .NET Framework](https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls). Make sure to backup registry before making changes.

### 💡 TLS 1.0 to TLS 1.2 – Final Solution

**PowerShell Team (on 17th of April 2020)** has released a new **PowerShellGet**, which solves the issue with **TLS 1.2** requirement.

```powershell
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
install-module powershellget -force -SkipPublisherCheck -Scope CurrentUser -AllowClobber
```

I've tested this on **Windows 2008R2** without **administrative rights**, and it solves the issue.

## Powiązane projekty

Projekty powiązane z tagami, kategoriami i treścią tego wpisu.

[Wszystkie projekty](/projekty/)

Trwa dopasowywanie projektów...

[Powrót do bloga](/blog/)

## Powiązane wpisy

- [Check an API write after a PowerShell timeout](/blog/verify-uncertain-api-outcomes-powershell/)
- [Inspect and convert mixed Office archives with PSWriteOffice](/blog/inspect-and-convert-mixed-office-archives-pswriteoffice/)
- [Compose PDF reports and automate page workflows with PSWriteOffice](/blog/automate-pdf-reports-and-page-workflows-pswriteoffice/)

<!-- PowerForge markdown artifact sha256:AED5A5AB19A35185134C3F9EC3045B9F336AAE1AD32BA38CDB7E5CF53A97BB5C -->
