Update Invoke-WebRequest HTTPS Protocol

If you’re trying to talk to a web server via PowerShell with the Invoke-WebRequest command, you may get an error: Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.

While I’m sure there are other situations that can cause this error message, it is the error you’ll get if the server you’re talking to has disabled SSLv3 and TLS1.0.

To make a connection, you’ll need to tell PowerShell to use something newer.  The following command will tell it to use TLS1.2.

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

 

Leave a comment