Adding TLS 1.2 support for Powershell (2024)

Adding TLS 1.2 support for Powershell

Fix an error downloading from the Powershell Gallery

Sometimes I try to setup PSWindowsUpdate (an amazing module from the Powershell Gallery) and receive an error like this one:

WARNING: Source Location https://www.powershellgallery.com/api/v2/package/PSWindowsUpdate/2.2.0.2' is not valid.PackageManagement\Install-Package : Package ‘PSWindowsUpdate' 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\... :String) [Install-Package], Exception+ FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage 

A similar issue arises with using the Invoke-WebRequest cmdlet. The root cause is that Powershell is trying to connect to a site and there’s no agreement on the encryption protocol to use. By default, Powershell uses TLS 1.0 and that’s been widely deprecated.

The Background

Transport Layer Security (TLS) is the successor to SSL. Starting in 2018, there was a groundswell of (good) advice that TLS 1.0 and 1.1 should be deprecated on websites and in browsers. This was largely adopted across the internet by 2020. That leaves TLS 1.2 as the de facto standard, with TLS 1.3 adoption rising but not as widespread yet.

The Problem

In April 2020, Microsoft disabled support for TLS 1.0 on the Powershell Gallery and now requires TLS 1.2. The issue is that Powershell 5.1 doesn’t support this configuration out of the box and the PowershellGet module (1.0.0.1) didn’t support TLS 1.2 at all. Smooth move, Microsoft.

The Solution

Microsoft released a new version of PowershellGet (2.2.4) in April 2020 that supports TLS 1.2. You can install it like this:

Install-Module PowerShellGet -RequiredVersion 2.2.4 -SkipPublisherCheck

By default, Powershell uses whatever the system default settings for crypto:

PS > [Net.ServicePointManager]::SecurityProtocolSystemDefault

… but the problem is that the default for each system could be different. You can force your system to enable TLS 1.2 support in your Powershell session:

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

… but the problem with this command is that you need to run it everytime you open a new Powershell session.

Let’s update the current user’s Powershell profile (creating it if it doesn’t exist) so that TLS 1.2 support is enabled every time a session is launched:

$ProfileFile = "${PsHome}\Profile.ps1"if (! (Test-Path $ProfileFile)) {New-Item -Path $ProfileFile -Type file -Force}'[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12' | Out-File -FilePath $ProfileFile -Encoding ascii -Append

Actually, while we’re at it, let’s configure Windows and .NET too:

#TLS1.2-Windows.ps1<#Enable only TLS 1.2 on Windows.Disable TLS 1.0, 1.2Enable .NET to use TLS 1.2Greg Beifuss2020-07-02 16:11#>New-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server' -Name 'Enabled' -Value '0' -PropertyType 'DWord' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server' -Name 'DisabledByDefault' -Value 1 -PropertyType 'DWord' -Force | Out-NullNew-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client' -Name 'Enabled' -Value '0' -PropertyType 'DWord' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client' -Name 'DisabledByDefault' -Value 1 -PropertyType 'DWord' -Force | Out-NullWrite-Host 'TLS 1.0 has been Disabled.'New-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server' -Name 'Enabled' -Value '0' -PropertyType 'DWord' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server' -Name 'DisabledByDefault' -Value 1 -PropertyType 'DWord' -Force | Out-NullNew-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client' -Name 'Enabled' -Value '0' -PropertyType 'DWord' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client' -Name 'DisabledByDefault' -Value 1 -PropertyType 'DWord' -Force | Out-NullWrite-Host 'TLS 1.1 has been Disabled.'New-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server' -Name 'Enabled' -Value '1' -PropertyType 'DWord' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server' -Name 'DisabledByDefault' -Value 0 -PropertyType 'DWord' -Force | Out-NullNew-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client' -Name 'Enabled' -Value '1' -PropertyType 'DWord' -Force | Out-NullNew-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client' -Name 'DisabledByDefault' -Value 0 -PropertyType 'DWord' -Force | Out-NullWrite-Host 'TLS 1.2 has been Enabled.'Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWordSet-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Adding TLS 1.2 support for Powershell (2024)
Top Articles
Can Real Estate Agents Give Referral Fees?
XP
Golden Abyss - Chapter 5 - Lunar_Angel
Public Opinion Obituaries Chambersburg Pa
Matgyn
Le Blanc Los Cabos - Los Cabos – Le Blanc Spa Resort Adults-Only All Inclusive
Lifewitceee
Jefferey Dahmer Autopsy Photos
Es.cvs.com/Otchs/Devoted
Shorthand: The Write Way to Speed Up Communication
Gameday Red Sox
Craigslist Dog Sitter
Our History | Lilly Grove Missionary Baptist Church - Houston, TX
Purple Crip Strain Leafly
Evangeline Downs Racetrack Entries
FAQ: Pressure-Treated Wood
Sams Early Hours
Tracking Your Shipments with Maher Terminal
2021 Lexus IS for sale - Richardson, TX - craigslist
Kvta Ventura News
50 Shades Darker Movie 123Movies
Urban Airship Expands its Mobile Platform to Transform Customer Communications
Copart Atlanta South Ga
ZURU - XSHOT - Insanity Mad Mega Barrel - Speelgoedblaster - Met 72 pijltjes | bol
Craigslist Appomattox Va
Quadcitiesdaily
Ahn Waterworks Urgent Care
683 Job Calls
Baldur's Gate 3: Should You Obey Vlaakith?
Mandy Rose - WWE News, Rumors, & Updates
Roanoke Skipthegames Com
Divide Fusion Stretch Hoodie Daunenjacke für Herren | oliv
2004 Honda Odyssey Firing Order
Gesichtspflege & Gesichtscreme
Downloahub
Vip Lounge Odu
Laveen Modern Dentistry And Orthodontics Laveen Village Az
Scat Ladyboy
Jambus - Definition, Beispiele, Merkmale, Wirkung
Car Crash On 5 Freeway Today
Tyler Sis 360 Boonville Mo
Craigslist Lakeside Az
Greater Keene Men's Softball
„Wir sind gut positioniert“
Craigslist Putnam Valley Ny
Discover Wisconsin Season 16
Charli D'amelio Bj
Craigslist Binghamton Cars And Trucks By Owner
Gw2 Support Specter
De boeken van Val McDermid op volgorde
Evil Dead Rise - Everything You Need To Know
The Significance Of The Haitian Revolution Was That It Weegy
Latest Posts
Article information

Author: Cheryll Lueilwitz

Last Updated:

Views: 6221

Rating: 4.3 / 5 (74 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Cheryll Lueilwitz

Birthday: 1997-12-23

Address: 4653 O'Kon Hill, Lake Juanstad, AR 65469

Phone: +494124489301

Job: Marketing Representative

Hobby: Reading, Ice skating, Foraging, BASE jumping, Hiking, Skateboarding, Kayaking

Introduction: My name is Cheryll Lueilwitz, I am a sparkling, clean, super, lucky, joyous, outstanding, lucky person who loves writing and wants to share my knowledge and understanding with you.