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 these error message, this 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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s