Powershell script to download file, having trouble setting up a secure connection

Brad is correct, but notice that PowerShell V1 doesn't really have native support for delegates, which you'll need in this specific case. I believe this should get you around that limitation (in fact the scenario you describe is exactly one of the examples used).


You need to write a callback handler for ServicePointManager.ServerCertificateValidationCallback.


If you are using powershell and face this error. Use command:

[Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12

before downloading the package. It forces PS to use TLS 1.2.

The reason for the failure could be the website you are trying to download from has disabled the support for TLS 1.0 which PS uses by default.

Tags:

Powershell