目标机器上的 PowerShell 在 TFS 2018 发布管道中失败

PowerShell on Target Machines Fails in TFS 2018 Release Pipeline

我是 TFS2018 的新手,我正在尝试配置 CI/CD 管道。我的构建成功,在我的发布管道中,我需要在我的部署服务器上使用 运行 powershell 脚本,所以我在目标机器任务上使用了 运行 PowerShell。我想,正确提供了所有必需的信息和 运行 版本,但在这个任务中得到如下错误

Connecting to remote server xxx.xxx.xx.xx failed with the following error message : The WinRM client cannot process the request. Default authentication may be used with an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.

请在下面找到我捕获的任务配置

我尝试将我的 TFS2018 服务器添加为目标服务器上的 trustedHost,但问题仍然存在。请建议和帮助。

这就是所谓的 PowerShell 双跃点问题,通常这意味着您正尝试使用不同的凭据登录远程计算机,然后您的用户 运行 使用的凭据。那么在您的情况下, $(adminUserName) 与代理相同吗?如果不是,那么您可以尝试将该用户更改为与代理相同。如果没有,那么您需要做更多的事情,然后将机器添加到 trustedHost。在 SPN 上观看此视频可能会有所帮助 https://www.youtube.com/watch?v=yFgdPcLOs-g and here is a detailed explanation on the double hop issue https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/ps-remoting-second-hop?view=powershell-7

  1. 通过powershell将TFS服务器机器添加到Target机器的TrustedHost。
    Set-Item WSMan:localhost\client\trustedhosts -value ServerDC

  2. 确保在此任务中提供的凭据具有管理员角色,同时在这种情况下他们可以访问 w.r.to TFS。如果提供的凭据没有 TFS 管理员特权,则任务无法调用代理来触发 VisualStudioRemoteDeployer.