先检查
代码语言:powershell复制[Enum]::GetNames([Net.SecurityProtocolType])
[Enum]::GetNames([Net.SecurityProtocolType]) -contains 'Tls12'
[System.Net.ServicePointManager]::SecurityProtocol.HasFlag([Net.SecurityProtocolType]::Tls12)
主要是看这句命令执行结果是不是True
代码语言:powershell复制[System.Net.ServicePointManager]::SecurityProtocol.HasFlag([Net.SecurityProtocolType]::Tls12)
不是的话,临时启用tls1.2,低版本系统比如2008R2的powershell想永久启用tls1.2参考https://cloud.tencent.com/developer/article/old/2288578,通过powershell配置文件实现。
代码语言:powershell复制[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
或
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
或
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
然后再在当前窗口再次执行上述检查tls1.2的命令
代码语言:powershell复制[System.Net.ServicePointManager]::SecurityProtocol.HasFlag([Net.SecurityProtocolType]::Tls12)
如果不支持tls1.2,执行这句命令会卡在Downloading,支持的话,会执行完成到下一行
代码语言:powershell复制Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
卡在Downloading https://onegetcdn.azureedge.net/providers/Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll
下图是支持tls1.2的情况