Last updated: Apr 4, 2024
Reading time·2 min
The PowerShell Invoke-WebRequest error "The request was aborted: Could not create SSL/TLS secure channel" occurs because PowerShell uses TLS 1.0 when connecting to websites by default but the site you are making a request to requires TLS 1.1 or TLS 1.2 or SSLv3.
To solve the error, use the SecurityProtocol
property to specify that all
protocols are supported.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Ssl3 [Net.ServicePointManager]::SecurityProtocol = "Tls, Tls11, Tls12, Ssl3"
You can copy the commands and paste them into PowerShell by pressing Ctrl
+
V
.
Once you paste the commands, rerun your Invoke-WebRequest
command.
Invoke-WebRequest -Uri https://nasa.gov
When you run the command you might get another error:
If you get the error rerun the command with the -UseBasicParsing
parameter.
Invoke-WebRequest -Uri https://nasa.gov -UseBasicParsing
Setting the parameter is necessary on machines where Internet Explorer is not installed or configured.
Note that you should be able to only use a single command to specify that all security protocols should be used.
The following should be sufficient.
[Net.ServicePointManager]::SecurityProtocol = "Tls, Tls11, Tls12, Ssl3" Invoke-WebRequest -Uri https://nasa.gov -UseBasicParsing
If you decide to use the alternative, more verbose command, you can wrap it into multiple multiple lines by ending each line with a backtick `.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor ` [Net.SecurityProtocolType]::Tls11 -bor ` [Net.SecurityProtocolType]::Tls -bor ` [Net.SecurityProtocolType]::Ssl3 Invoke-WebRequest -Uri https://nasa.gov -UseBasicParsing
The Invoke-WebRequest
PowerShell command is used to get the content of a web
page on the internet.
You can view examples of using the command in this section of the Microsoft docs.
You can learn more about the related topics by checking out the following tutorials: