使用 powershell 中的 irm 命令时提示如下错误
# irm:请求被中止:未能创建 SSL/TLS 安全通道
CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod],WebExce
ption
FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
故障原因是脚本网站使用的 SSL 协议版本是 TLS 1.2,而 irm 默认使用的 TLS 1.3, 我们可以通过以下命令切换到 TLS 1.2 来完成操作。
# 切换到 TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12