0
votes

I'm working on integration of automated UI functional tests into non-XAML TFS build.

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

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.

I ran into issues with step 5 (Visual Studio Test Agent Deployment); the following error was returned:

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 https://aka.ms/remotevstest.

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).

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.

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.

I've been struggling with this issue for some time now; I'd very much appreciate any insights that may help to resolve.

Thanks for looking.

UPDATE:

Hi Andy, thanks for looking & answering.

I followed the steps as per your suggestions:

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.

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..."

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.

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."

Further attempts to remotely execute the PS1 script on the server return the original error.

My test agent server is running Windows Server 2012 R2, I am using PowerShell version 4.0.

2
What's the OS version of the VM which hosting your Test Agent?Andy Li-MSFT
Test agent VM is running Windows Server 2012 R2.The Furious Bear

2 Answers

1
votes

According to the error message, it's due to an issue in the WinRM configuration.

Make sure you have enabled the PSRemoting on your build agent and target machine, run command Enable-PSRemoting -Force.

Please try below things to narrow down the issue:

  • This may related to the package KB2883200 for Windows 8.1 and Windows Server 2012 R2. So, in this case you can check if you have installed the patch KB2883200 , if not just download and install it, then try it again (You may need to restart the VM after
    installing the KB).
  • Check if you have enabled the PSRemoting on the Test Agent VM:

    1. Remote to the VM, run PowerShell with administrator, run command :

      Enter-PSSession localhost

    2. If this fails, then you need to enable PSRemoting by running below command :

      Enable-PSRemoting

    3. If this does not work or it says that it is already set up, then try to run the following command:

      Enable-PSRemoting -Force

Besides, you can reference below article for configuring the WinRM service manually:

How to Run PowerShell Commands on Remote Computers

1
votes

Okay, as I indicated earlier in my update to the original post, I had exhausted (repeatedly) the recommendations provided above by Andy and elsewhere.

Even though the execution of the 'Enable-PSRemoting -Force' cmdlet has returned "WinRM is already set up to receive requests on this computer. WinRM is already set up for remote management on this computer.", in the test agent server's management console, (under Local Computer Policy\Computer Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Service\), the setting 'Allow remote server management through WinRM' was marked 'Not configured'.

I updated this to 'Enabled'.

I then created a new inbound rule in the Windows Firewall (prompted when updating WinRM service config above), configuring to allow secure connections, adding my specified build server, via the default TCP port 5985.

This solved the problem.