title: PowerShell Remoting error with TFS build Visual Studio Test Agent Deployment task
body: <p>I'm working on integration of automated UI functional tests into non-XAML TFS build.</p>
  
  <p>My build definition specifies the following build steps:
       - Get Sources
       - NuGet Installer
       - MSBuild
       - Windows Machine File Copy
       - Visual Studio Test Agent Deployment
       - Run Functional Tests</p>
  
  <p>The first four steps complete successfully. Step 4 (Windows Machine File Copy) copies our test project application folder contents from our build server to another remote VM, hosting our Test Agent. The intention is to complete the build (as currently set up) on the build server, then copy the test project to the test agent server, deploy the test agent and run the functional tests on the test VM.</p>
  
  <p>I ran into issues with step 5 (Visual Studio Test Agent Deployment); the following error was returned:</p>
  
  <blockquote>
    <p>Error occurred on ''[server_name]:5986'. Details : 'Connecting to remote server [server_name] failed with the following error message : The client cannot connect to the destination      specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic.'. For troubleshooting, refer <a href="https://aka.ms/remotevstest" rel="nofollow noreferrer">https://aka.ms/remotevstest</a>.</p>
  </blockquote>
  
  <p>My research into this error indicates that the problem is associated with PowerShell Remoting, rather than the TFS build (the TFS build task wraps a PowerShell command to be executed on the remote VM). </p>
  
  <p>I have checked and double-checked that the WinRM service on the target (test agent) server as per error message suggestion; the WinRM service is on and is configured to accept requests. I have also run the "winrm quickconfig" command as per suggestion. Still the issue persists.</p>
  
  <p>Our servers are on the same domain. I have administrative privileges on the test agent (remote) VM but no access to the build (local) VM.</p>
  
  <p>I've been struggling with this issue for some time now; I'd very much appreciate any insights that may help to resolve.</p>
  
  <p>Thanks for looking.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Hi Andy, thanks for looking &amp; answering.</p>
  
  <p>I followed the steps as per your suggestions:</p>
  
  <p>Following the link you provided, Windows 8.1 and Windows Server 2012 R2, I found that "Important This update has been superseded by update 2919355 ." Having checked my test agent box, update 2919355 has been installed.</p>
  
  <p>The 'Enter-PSSession localhost' cmdlet returned the error: 
  "Connecting to remote server localhost failed with the following error message : The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was not available. This is usually returned by a HTTP server that does not support the WS-Management protocol..."</p>
  
  <p>I then executed 'Enable-PSRemoting' as per suggestion and confirmed 'Yes' to perform each action. After this, another execution of 'Enter-PSSession localhost' returned the same error as before.</p>
  
  <p>Finally, I once again tried 'Enable-PSRemoting -Force'; this returned:
  "WinRM is already set up to receive requests on this computer.
  WinRM is already set up for remote management on this computer."</p>
  
  <p>Further attempts to remotely execute the PS1 script on the server return the original error.</p>
  
  <p>My test agent server is running Windows Server 2012 R2, I am using PowerShell version 4.0.</p>