Powershell Setting Security Protocol to Tls 1.2 [duplicate]

别等时光非礼了梦想. 提交于 2019-12-19 09:59:05

问题


I am using this code

        $WebClient = New-Object system.net.webclient
        $WebClient.credentials = New-Object System.Net.NetworkCredential -ArgumentList $username, $password
        $WebClient.Proxy = $null
        $WebClient.Headers.Add("COperation","MethodCall")
        $WebClient.Headers.Add("CMethod", "EnumerateInstances")
        $WebClient.Headers.Add("CObject", $NameSpace)
        $WebClient.Headers.Add("Content-Type", "application/xml")
        $System= $WebClient.UploadString($Url, "POST", $EnumMessage)

This works well. What I want to do is that set the Security Protocol to Tls1.2 or Tls1.1. Please help.


回答1:


setting this should change the protocol :

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;

PS : checked in powershell v5

Setting Multiple Security Protocols:

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls12;


来源:https://stackoverflow.com/questions/41674518/powershell-setting-security-protocol-to-tls-1-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!