Invoke-WebRequest and underlying connection was closed

I’m using Powershell v5.1 and Octopus Deploy v2018.7.3 to run a simple command to call google.com (just for testing)

Here’s the Script:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$Project = Invoke-WebRequest ‘https:\google.com

But I keep getting an error. Attaching an image of the error.

Hi @ppande,

Thanks for getting in touch!

It appears that the problem is the security level for Internet Explorer, as I presume you are attempting to run this script on a machine running Windows Server. I have the same issue running this script on Windows Server 2012 and 2016, however when I run it on Windows 10 it works perfectly.

I quickly tried reducing the security level on my Server instance and still had the same issue, so it might be something deeper here but it is definitely OS related.

Sorry I couldn’t be more help,

Regards
Alex

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.