Azure Cmdlet Add-AzureRmAccount不适用于公司行

我目前正在学习如何使用PowerShell资源pipe理cmdlet创buildazure色的环境。
经典的工作方式没有问题,我可以使用Add-AzureAccount ,它可以让我访问我的订阅。

但是,使用新的资源pipe理器cmdlet时,当我使用Add-AzureRmAccount我得到两个错误之一。

使用$Cred = Get-Credentials使用存储凭据,然后使用Add-AzureRmAccount -Credential $credlogin时,会收到以下错误:

访问ws元数据交换失败。

使用login提示时。 这意味着我只需inputAdd-AzureRmAccount ,它会将我转到我公司的SSO页面。 我在哪里login成功。 我得到以下错误:

发送请求时发生错误。

当我尝试从家中使用该cmdlet时,使用vpn连接到之前使用的同一台笔记本电脑。 我可以使用Add-AzureRmAccount并按照login提示完美连接。 使用存储的$cred entials仍然失败,元数据交换错误。

我假设存储的凭据方法失败,因为它不能redirect到没有交互式提示的SSO。
但是,我不确定什么可能导致交互式login失败,因为我可以清楚地到达SSO,并且Add-AzureAccount cmdlet在同一台计算机上工作。

Add-AzureAccountAdd-AzureRmAccount cmdlet有什么不同?

更新:

完整的堆栈跟踪错误是:

 Message : An error occurred while sending the request. Data : {} InnerException : System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required. at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) TargetSite : Void ThrowForNonSuccess(System.Threading.Tasks.Task) StackTrace : at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) at Microsoft.Azure.Subscriptions.TenantOperationsExtensions.List(ITenantOperations operations) at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.ListAccountTenants(AzureAccount account, AzureEnvironment environment, SecureString password, ShowDialog promptBehavior) at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.Login(AzureAccount account, AzureEnvironment environment, String tenantId, String subscriptionId, String subscriptionName, SecureString password) at Microsoft.Azure.Commands.Profile.AddAzureRMAccountCommand.ProcessRecord() at System.Management.Automation.Cmdlet.DoProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() HelpLink : Source : Microsoft.Threading.Tasks HResult : -2146233088 

看起来像我的错误是防火墙相关的。
我不确定为什么一个命令( Add-AzureRmAccount )遇到错误,而旧版本( Add-AzureAccount )没有。

根据Colyn1337提出的关于可能基于web的api的差异的评论。
而authentication错误与代理服务器没有正确authentication有关。

一个类似的问题,在一个不同的,也是基于web的api cmdlet,有一个类似的错误,提供了解决scheme。
正如答案中提到的那样,我只需在脚本的开头添加下面的代码:

 [System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials