Solved Invoke-WebRequest sometimes fails to connect to https
-
So I am trying to push out my MeshCentral agent via ScreenConnect's command function.
Well it works on some computer, but not others.
I'm getting hit by
Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.
It works on some computers but not on others.
Command being used:
#!ps #maxlength=100000 #timeout=90000 $url_client_a = 'https://mc.bundystl.com/meshagents?id=4&meshid=>snip<&installflags=0' Invoke-WebRequest -OutFile c:\meshagent.exe $url_client_a
Edit: This is the workign command:
#!ps #maxlength=100000 #timeout=90000 [Net.ServicePointManager]::SecurityProtocol = "tls12" $url_client_a = 'https://mc.bundystl.com/meshagents?id=4&meshid=>snip<&installflags=0' Invoke-WebRequest -OutFile c:\meshagent.exe $url_client_a
-
@JaredBusch said in Invoke-WebRequest sometimes fails to connect to https:
The request was aborted: Could not create SSL/TLS secure channel.
Could this be a TLS issue? Perhaps the version of PowerShell on one computer is using TLS1 and the others are using TLS1.2?
Your site appears to support 1.2 and 1.3 only so perhaps the following added to your PS script before the WebRequest will work:
[Net.ServicePointManager]::SecurityProtocol = "tls12"
-
@manxam said in Invoke-WebRequest sometimes fails to connect to https:
@JaredBusch said in Invoke-WebRequest sometimes fails to connect to https:
The request was aborted: Could not create SSL/TLS secure channel.
Could this be a TLS issue? Perhaps the version of PowerShell on one computer is using TLS1 and the others are using TLS1.2?
Your site appears to support 1.2 and 1.3 only so perhaps the following added to your PS script before the WebRequest will work:
[Net.ServicePointManager]::SecurityProtocol = "tls12"
That did it for one system. let me test a couple others.
-
worked on all the ones i tested that had failed.
-
Please update the OP with the new command.
Thanks.
-
@Dashrender said in Invoke-WebRequest sometimes fails to connect to https:
Please update the OP with the new command.
Thanks.
updated
-
@JaredBusch : Awesome! Glad to hear it worked for you...