iT邦幫忙

0

Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.

  • 分享至 

  • xImage

執行Invoke-WebRequest遇到以下錯誤訊息,網上查到需要在指令前加上以下指令,但還是一樣錯誤,目前已知要連線的Server有enable TLS1.2(only),service使用https,firewall有通,telnet servicename 443有通,而執行PowerShell的Server有enable TLS1.0、1.1、1.2,PowerShell使用v4.0。
作為對照,我使用自己的電腦,執行Invoke-WebRequest是成功,只是PowerShell是v5.1,不知道是否是PowerShell版本問題?
請各位協助,謝謝。

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
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
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
尼克
iT邦大師 1 級 ‧ 2022-03-16 17:32:43
看更多先前的回應...收起先前的回應...
eric1223 iT邦新手 5 級 ‧ 2022-03-16 17:43:19 檢舉

試過了,他的方法就是在指令前面加上[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
對我的狀況來說,錯誤依舊。

nwm310 iT邦新手 4 級 ‧ 2022-03-16 19:42:59 檢舉
[Net.ServicePointManager]::SecurityProtocol = 192 + 768 + 3072

可以嗎?

eric1223 iT邦新手 5 級 ‧ 2022-03-17 09:49:46 檢舉

一樣錯誤訊息

eric1223 iT邦新手 5 級 ‧ 2022-03-17 09:55:43 檢舉

我請對方把VM的TLS1.0、1.1啟用,但還是一樣的錯誤訊息。
同時,我在其他地方看到PowerShell出現TLS1.2的錯誤訊息了,跟我的錯誤訊息不同,會不會是其他問題導致這個錯誤?

尼克 iT邦大師 1 級 ‧ 2022-03-17 10:43:02 檢舉

你可以需要用你的關鍵字查詢!超出我的領域了。

尼克 iT邦大師 1 級 ‧ 2022-03-17 10:58:29 檢舉

我要發表回答

立即登入回答