Connect-MsolService:向https://provisioningapi.microsoftonline.com/provisioningwebservice.svc发出HTTP请求时发生错误

时间:2019-01-06 04:15:51

标签: powershell powershell-v3.0 powershell-v4.0 azure-powershell powershell-remoting

为什么我会随机出现此错误。,Powershell脚本有时会正常工作,有时无法正常工作并抛出以下错误。

    Connect-MsolService : An error occurred while making the HTTP request to 
    https://provisioningapi.microsoftonline.com/provisioningwebservice.svc. This could be due to the fact that the server 
    certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the 
    security binding between the client and the server.
At D:\O365License\Licensing.ps1:28 char:1
+ Connect-MsolService -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [Connect-MsolService], CommunicationException
    + FullyQualifiedErrorId : 
System.ServiceModel.CommunicationException,Microsoft.Online.Administration.Automation.ConnectMsolService  

1 个答案:

答案 0 :(得分:0)

您可能会遇到与TLS 1.2有关的.NET相关问题。在运行Connect-MsolService命令之前,请尝试运行此命令。

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