我正在使用此代码
$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)
这很好用.我想要做的是将安全协议设置为Tls1.2或Tls1.1.请帮忙.
设置这应该改变协议:
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
PS:签入powershell v5
设置多个安全协议:
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls12;