You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows Server 2016上Invoke-WebRequest发送永久错误排查求助

问题:PowerShell通过代理监控CrowdStrike端点时连接失败

我在Windows Server 2016系统上使用PowerShell v5.1编写脚本,通过公司专用代理监控CrowdStrike云端点https://ts01-b.cloudsink.net的可用性,脚本代码如下:

$URLAddress = "https://ts01-b.cloudsink.net"
$ProxyAddress = "http://proxyout.dev:8080"

$response = $null
$errorcode = $null

[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"


try
{
$request = Invoke-WebRequest -Uri $URLAddress -Method Get -UseBasicParsing -DisableKeepAlive -MaximumRedirection 0 -Proxy $ProxyAddress -ProxyUseDefaultCredentials

$response = $request.StatusCode
Write-Host "Status Code -- $response"
}
catch
{
$errormessage = $_.Exception.Message
$errorcode = $_.Exception.Response.StatusCode.Value__
}


IF ($response -eq '200')
{
IF ($errorcode -eq $null)
{
  Write-Host "url: ""$URLAddress"" is avalible. `nStatus Code: $response"

}
ELSE
{
  Write-Host "url: ""$URLAddress"" is avalible but porxy: ""$proxydev"" has an error, `nError Code: $errorcode `nError Message:`n$errormessage. `nStatus Code: $response"
}
}
ELSE
{
  Write-Host "url: ""$URLAddress"" is not avalible. `nStatus Code: $response `nError Code: $errorcode `nError Message:`n$errormessage"
}

$request.BaseResponse.Close() 

脚本运行时持续出现错误:

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

奇怪的是,在目标服务器本地运行该脚本却完全正常。

通过SSL报告分析确认,ts01-b.cloudsink.net使用TLS 1.2版本,因此无需绕过SSL证书校验(如[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}这类常见方案)。

需要说明的是,出现问题的服务器供公司其他开发者频繁使用,他们常手动或通过微软SCOM监控代理运行PowerShell脚本。我无法确定问题根源,想问有没有人遇到过类似问题?

内容的提问来源于stack exchange,提问作者edwio

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 08:50:47