5
votes

I have a problem with running mstest.exe remotely using powershell. I need it to run automated tests on other machine.
I try to do the next command:

Invoke-command -ComputerName remoteComputer" -ScriptBlock { & "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\mstest.exe" "/testcontainer:myTests.dll"}  

And after that I get the next error:
Failed to queue test run 'username@machinename 2017-10-03 13:30:18': Unable to start the agent process.
So I see that mstest was started and tests were loaded but it can't start agnet process.
I tried to specify credentials but the same. Though I'm admin on both machines and run powershell as administrator.
When I run the same command on the remote machine locally in cmd then mstest works correctly. Did anyone has the similar issue?

3
I am having similar issue. How did you resolve the issue? - Maalamaal
any luck with this issue? - Ashish Musale
Have you checked that the .NET that is being used is up to date? - Neoxidine
Have you logged into the remote computer with the user being used to run the remote command? I've seen where remote commands don't create a proper user profile, and programs expect to run in a proper user profile. - VertigoRay
@VertigoRay - Yes ive logged in with the user being used to run the remote command - the profile is proper and the batch file is working fine when being executed directly in the remote system but not working if i try to execute the batch from my system using a powershell. - Anu7

3 Answers

0
votes

Have you tried running something like:

Invoke-Command -Computer remote -ScriptBlock {Start-Process <mstest details>...}

The Invoke-Command should get you the remote access, the Start-Process should run the mstest

0
votes

I don't know too much about how mstest works.

Try to create a schedule task in the remote computer with all you need and in your Script Block just call this task

I'm sure this is not the best way, but try to do this.

The task will run locally and I think the mstest will run without any problem.

0
votes

When you run mstest.exe remotely using powershell you need to add "/noisolation" property to the command in the script block:

Invoke-command -ComputerName remoteComputer" -ScriptBlock { & "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\mstest.exe" "/testcontainer:myTests.dll" "/noisolation" }