Posted on

Powershell Invoke-WebRequest Fails with SSL/TLS Secure Channel

Scenario

you are trying to execute this powershell command

Invoke-WebRequest -Uri https://mysite.com/

and you get this error. “Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.”

Solution

The cause of the error is Powershell by default uses TLS 1.0 to connect to website, but website security requires TLS 1.2. You can change this behavior by placing the following command before the request method

 

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri https://mysite.com/