TFS 2017 - 运行 来自 TFS 服务器而非代理的 powershell 脚本

TFS 2017 - Run powershell script from TFS server, not agent

有没有办法在发布期间从实际的 TFS 服务器 运行 powershell 脚本?我 运行 在 docker 容器中构建代理,它没有加入域,因此 wmi 不允许 docker 容器中的 windows 代理停止在复制新的工件文件之前,网络服务器上的应用程序池,即使我在连接之前指定了凭据。如果我可以 运行 来自 TFS 2017 服务器的 powershell 脚本,这个问题就会得到解决。

我得到的错误是:

019-08-30T13:49:44.6542238Z ##[error][<server>.<domain>.com] Connecting to remote server <server>.<domain>.com failed with the following error message : The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. You can get more information about that by running the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (<server>.<domain>.com:String) [], PSRemotingTransportException + FullyQualifiedErrorId : ServerNotTrusted,PSSessionStateBroken

我一直忽略 docker windows servercore tfs 代理容器,认为它一定与我试图将文件复制到的服务器有关,但事实并非如此。出于某种原因,我所要做的就是将以下内容添加到我的 tfs 代理中:

winrm 设置 winrm/config/client @{TrustedHosts="machineA,machineB"}

现在一切正常。我从 wsam 中删除了所有受信任的主机,它仍然有效。我想是因为我在我的 powershell 脚本中使用了凭据...不确定,但我很高兴。