如何通过 PowerShell 确认 TLS 1.2 在操作系统上可用?

A X*_*A X 5 powershell tls1.2

在 Windows Server 2016 中,可以通过组策略禁用 TLS 1.2。

我们希望在 PowerShell 中的安装程序脚本中添加检查,以查看 TLS 1.2 是否可用。请注意,这与检查 URL 是否使用 TLS 1.2,或者当前 PowerShell 会话中是否启用 TLS 1.2 不同。我们想检查 TLS 1.2 是否可从操作系统使用,或者是否已通过管理员组策略配置禁用。

有谁知道如何做到这一点?任何帮助将不胜感激。网上没有关于这个主题的详细信息。

mkl*_*nt0 5

使用以下内容:

$available = try {
  $orig = [Net.ServicePointManager]::SecurityProtocol
  [Net.ServicePointManager]::SecurityProtocol = 'Tls12'
  [bool] [System.Net.WebRequest]::Create('https://example.org/')
} catch {
  $false
} finally {
  [Net.ServicePointManager]::SecurityProtocol = $orig
}
Run Code Online (Sandbox Code Playgroud)