TFS task Run Power shell on remote machine Error: System.Management.Automation.RuntimeException: Failed to install 'VisualStudioRemoteDeployer'

TFS task Run Power shell on remote machine Error: System.Management.Automation.RuntimeException: Failed to install 'VisualStudioRemoteDeployer'

在我的 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.

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