1

Is there a way to run a powershell script from the actual TFS server during a release? I am running the build agent in a docker container and it's not joined to the domain so wmi won't allow the windows agent in the docker container to stop the app pool on the webserver before copying over new artifact files, even though I specify credentials before connecting. If I could run the powershell script from the TFS 2017 server this problem would be solved.

The error I get is:

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

Post Impatica
  • 10,585
  • 5
  • 48
  • 61
  • I tried to add the internal ip of the docker container to the WSMan trusted host list and it still doesn't work – Post Impatica Aug 30 '19 at 14:25
  • The answer to the question you asked is a straight "No". The solution to the problem you're actually facing is more complicated. You need to add the IP address of the machine the container is running on to trusted hosts, *not* the internal IP of the container -- the internal IP of the container is irrelevant outside of the docker environment. – Daniel Mann Aug 30 '19 at 19:19

1 Answers1

0

I kept ignoring the docker windows servercore tfs agent container thinking it must have something to do with the server I'm trying to copy files to but it wasn't. For some reason all I had to do was add the following to my tfs agent:

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

Now everything works. I removed all trustedhosts from wsam and it still works. I guess because I'm using credentials in my powershell scripts...not sure but I'm happy.

Post Impatica
  • 10,585
  • 5
  • 48
  • 61
  • Thanks for your kindly sharing, you could ***mark your reply as an answer***, which will also helps others in the community. – PatrickLu-MSFT Sep 02 '19 at 01:57