Force powershell to use TLS.1.2

Hello everybody. I recently had a problem when trying to install a powershell module on my Windows Server 2016.

I wanted to install AzureAD and AzureRM module and Windows tells my that I need a dependency, NuGet.

Install-Module -Name AzureAD
Install-Module -Name AzureRM

I got this error:

WARNING: Unable to download from URI '' to ''

I tried to access manually to the given URL and all is working. That means my powershell use a different configuration to access HTTP than my browser.

After some research, I find a solution that forces PowerShell session to use TLS 1.2 for HTTPS connection. To force the use of TLS 1.2, simply execute the following command:

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

After that, I tried again to execute the command this install module (and the needed dependency) and all worked perfectly.

Hope this will help.

Bookmark the permalink.

Comments are closed.