The following error message is encountered when executing Invoke-WebRequest. It is found on the Internet that the following command needs to be added before the command, but the error is still the same.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
At present, it is known that the server to be connected has enable TLS1.2 (only), the service uses https, the firewall is connected, and the telnet servicename 443 is connected, and the server that executes PowerShell has enable TLS1.0, 1.1, 1.2, and PowerShell uses v4. 0. As a comparison, I use my own computer and execute Invoke-WebRequest successfully, but PowerShell is v5.1. I wonder if it is a PowerShell version problem? Please help, thank you.
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At line:1 char:15
+ $WebConnect = Invoke-WebRequest -URI $strHTTPS -Credential $credential
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand