TFS 任务在远程计算机上运行 Power shell 错误:System.Management.Automation.RuntimeException:无法安装“VisualStudioRemote

Posted

技术标签:

【中文标题】TFS 任务在远程计算机上运行 Power shell 错误:System.Management.Automation.RuntimeException:无法安装“VisualStudioRemoteDeployer”【英文标题】:TFS task Run Power shell on remote machine Error: System.Management.Automation.RuntimeException: Failed to install 'VisualStudioRemoteDeployer' 【发布时间】:2020-08-19 21:59:43 【问题描述】:

在我的 TFS 2018 CD 中,我有一个任务“在远程机器上运行 PowerShell”,它失败并出现如下错误

System.Management.Automation.RuntimeException: Failed to install 'VisualStudioRemoteDeployer

找到如下任务配置

找到完整的错误日志如下

2020-05-05T06:49:22.4862201Z Exception calling "SetRight" with "2" argument(s): "Could not obtain the user information." 2020-05-05T06:49:22.4862692Z CategoryInfo :NotSpecified: (:) [], MethodInvocationException 2020-05-05T06:49:22.4862987Z FullyQualifiedErrorId :Exception 2020-05-05T06:49:22.4863348Z ---> System.Management.Automation.RemoteException: Exception calling "SetRight" with "2" argument(s): "Could not obtain the user information." 2020-05-05T06:49:22.4863751Z --- End of inner exception stack trace --- 2020-05-05T06:49:22.4864154Z at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.PowershellExecutor.Invoke(String errorContextMessage, Boolean writeResultToLog, Boolean isCancellable) 2020-05-05T06:49:22.4864655Z at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.RemoteDeploymentHelper.InstallServiceInternal(String serviceSourcePath, String serviceName, String destinationFileName) 2020-05-05T06:49:22.4865266Z at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.RemoteDeploymentHelper.InstallService(String serviceSourcePath, String serviceName, String destinationFileName) 2020-05-05T06:49:22.4865783Z at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.DeploymentClient.<RunAsync>d__24.MoveNext() 2020-05-05T06:49:22.4866260Z ---> (Inner Exception #0) System.Management.Automation.RemoteException: Exception calling "SetRight" with "2" argument(s): "Could not obtain the user information."<--- 2020-05-05T06:49:22.4866523Z 2020-05-05T06:49:22.4866665Z 2020-05-05T06:49:22.5010643Z Deployment status for machine 'XXXXX:5985' : 'Failed' 2020-05-05T06:49:22.5565354Z ##[error], MethodInvocationException\r\n FullyQualifiedErrorId :Exception\r\n";] 2020-05-05T06:49:22.5588511Z 2020-05-05T06:49:22.5588871Z 2020-05-05T06:49:22.5951437Z ##[error]System.Management.Automation.RuntimeException: Failed to install 'VisualStudioRemoteDeployerc87a55d0-555b-426c-b80f-1cf90ad0bf1c' from service executable path VisualStudioRemoteDeployer.exe . Consult the logs below: 2020-05-05T06:49:22.5952932Z Exception calling "SetRight" with "2" argument(s): "Could not obtain the user information." 2020-05-05T06:49:22.5953641Z CategoryInfo :NotSpecified: (:) [], MethodInvocationException 2020-05-05T06:49:22.5954109Z FullyQualifiedErrorId :Exception 2020-05-05T06:49:22.5954536Z ---> System.Management.Automation.RuntimeException: Failed to install 'VisualStudioRemoteDeployerc87a55d0-555b-426c-b80f-1cf90ad0bf1c' from service executable path VisualStudioRemoteDeployer.exe . Consult the logs below: 2020-05-05T06:49:22.5955018Z Exception calling "SetRight" with "2" argument(s): "Could not obtain the user information." 2020-05-05T06:49:22.5955350Z CategoryInfo :NotSpecified: (:) [], MethodInvocationException 2020-05-05T06:49:22.5955636Z FullyQualifiedErrorId :Exception 2020-05-05T06:49:22.5955873Z 2020-05-05T06:49:22.5956133Z --- End of inner exception stack trace --- 2020-05-05T06:49:22.5956455Z at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) 2020-05-05T06:49:22.5959512Z at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke) 2020-05-05T06:49:22.5959955Z at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync) 2020-05-05T06:49:22.5960388Z at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection1 输入,PSDataCollection1 output, PSInvocationSettings settings) 2020-05-05T06:49:22.5960842Z at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection1 输入,PSDataCollection1 output, PSInvocationSettings settings) 2020-05-05T06:49:22.5961295Z at Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args) 2020-05-05T06:49:22.6472008Z ##[error]LegacyVSTSPowerShellHost.exe completed with return code: -1.

【问题讨论】:

提供的用户凭据是管理员凭据吗? 是的,这些都是管理员角色 运行代理的账号在目标机器上是否有管理员权限? 【参考方案1】:

这看起来与this 问题非常相关。根本原因应该与用户访问有关。 确保配置中提供的用户凭据对目标机器和 TFS 具有管理员权限。这将解除阻止VisualStudioRemoteDeployer 运行并消除SetRight" with "2" argument(s): "Could not obtain the user information 问题。

【讨论】:

以上是关于TFS 任务在远程计算机上运行 Power shell 错误:System.Management.Automation.RuntimeException:无法安装“VisualStudioRemote的主要内容,如果未能解决你的问题,请参考以下文章

通过 Powershell 远程 TFS 签入

如何获得在没有 WMI 的远程计算机上运行的进程的所有者

您的代理计算机上未安装 SQL Powershell 模块。请按照以下步骤执行此任务

如何找出CMD.exe进程在远程计算机上运行的脚本?

目标机器上的 PowerShell -TFS 任务,在远程服务器中更改执行策略后安全警告仍然存在

如何以编程方式停止/启动远程计算机上的计划任务?