With the recent changes to TLS support in Office 365 and PowerShell there are times you need to update your TLS settings to force the best and/or only support versions. Times I’ve been hit with install-module not working in PowerShell sessions. Normally this works fix the issue connecting to NuGet:
1 |
[System.Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13 |
But there is a better way to use the best support with what ever operation required:
1 |
[System.Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13 -bor [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls11 |
This tries to use 1.3 first if supported, or 1.2 or even 1.1 if still in use. A single line forcing the best TLS acceptable.