Azure PowerShell无法在私有代理上的Azure Dev Ops内部运行

时间:2018-11-14 15:07:51

标签: azure powershell azure-devops azure-rm

我在Windows Server 2012 R2构建服务器上安装了64位专用代理。我已将此连接到Azure Dev Ops。在生成服务器上,我仅安装了5.6.0版的AzureRM,因为这是我要运行的脚本所必需的。如果您有兴趣,请参阅我的其他问题:How to set PITR for all databases in a Azure Sql Database Elastic Pool?

如果我在Azure DevOps中创建Azure PowerShell v3任务以运行以下内联脚本:

Get-Module -Name AzureRM* -ListAvailable

我收到此错误:

2018-11-14T13:26:56.0519566Z ==============================================================================
2018-11-14T13:26:56.0519655Z Task         : Azure PowerShell
2018-11-14T13:26:56.0519727Z Description  : Run a PowerShell script within an Azure environment
2018-11-14T13:26:56.0519782Z Version      : 3.1.7
2018-11-14T13:26:56.0519844Z Author       : Microsoft Corporation
2018-11-14T13:26:56.0520315Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613749)
2018-11-14T13:26:56.0520404Z ==============================================================================
2018-11-14T13:26:57.1508635Z Added TLS 1.2 in session.
2018-11-14T13:26:57.4439615Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\AzureRM\5.6.0\AzureRM.psd1 -Global
2018-11-14T13:26:58.6759005Z ##[error]The following error occurred while loading the extended type data file: Error in TypeData "Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer": The TypeConverter was ignored because it already occurs.
Error in TypeData "Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer": The member SerializationDepth is already present.
Error in TypeData "Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache": The member PropertySerializationSet is already present.
Error in TypeData "Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache": The member SerializationMethod is already present.
Error in TypeData "Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache": The member PropertySerializationSet is already present.
Error in TypeData "Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache": The member SerializationMethod is already present.
Error in TypeData "Microsoft.Azure.Commands.Profile.Models.PSAzureContext": The member SerializationDepth is already present.
Error in TypeData "Microsoft.Azure.Commands.Profile.Models.PSAzureProfile": The member SerializationDepth is already present.

如果我以构建服务器帐户登录到构建服务器并打开PowerShell窗口,则可以正常运行。在Azure DevOps中的常规PowerShell任务中,它也可以正常工作。

我的PowerShell脚本需要在Azure帐户的上下文中运行,如何实现?

编辑

我已经尝试过Azure PowerShell任务v1和v2,但没有用。我还尝试在版本选项部分中将PowerShell版本指定为5.6版本,以及最新安装的版本。这些都不起作用。

0 个答案:

没有答案