使用带有一个URI的Invoke-RestMethod cmdlet时,我遇到了一个问题。我得到的错误是“Invoke-RestMethod:底层连接已关闭:接收时发生意外错误。” 我已经在脚本中添加了以下代码,正如一些论坛中所建议的那样,这对我来说无法解决问题。有人可以帮忙吗?
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
提前致谢, Vino Jose