【发布时间】:2020-03-10 12:32:52
【问题描述】:
我有一个带有 powershell 4 的 Windows Server 2012R2。
一个 sql 作业发出一个
Invoke-WebRequest https://someserver/file.xml -OutFile c:/tmp/data.xml"
即使我遵循,它也会因 ssl 错误而失败
Powershell Invoke-WebRequest Fails with SSL/TLS Secure Channel 并在前面加上 [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" 或其他变体。
powershell 4 太旧了吗?
我应该尝试从https://github.com/PowerShell/PowerShell/releases 安装 Wowershell 6 还是 7?
这会被 sqljob 调用,还是应该在某处/以某种方式指定它应该运行 v7 而不是 v4?
PS:我知道“虽然 Windows Server 2012 R2 在 2013 年 11 月 25 日进入主流支持,但它的主流结束是 2018 年 1 月 9 日,扩展结束是 2023 年 1 月 10 日” 但现在升级不是一种选择。
编辑
我安装了powershell 5.1,没变
Major Minor Build Revision
----- ----- ----- --------
5 1 14409 1005
然后做
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
但仍然得到
Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.
编辑 2
PS C:\Users\leif> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
【问题讨论】:
-
对于 2012R2,我强烈建议安装 Windows Management Framework 5.1(包括 PowerShell 5.1),然后使用
[ServicePointManager]::SecurityProtocol = 'Tls12'重试
标签: powershell