I'm trying to execute mstest remotely via Invoke-Command in PowerShell. The PowerShell command within the scriptblock is a basic mstest call with a single test container and a specified results file. It works correctly if run from within RDP on the remote server.
However, if I run it remotely via Invoke-Command, mstest returns an exception
Failed to queue test run 'Administrator@AEPRFDLY00ALL00 2016-01-06 10:22:40': Unable to start the agent process.
Looking at event viewer on the remote machine, I see a series of exceptions, starting with:
(QTAgent32_40.exe, PID 2432, Thread 1) AgentProcess: Failed to get agent process proxy: System.Runtime.Remoting.RemotingException: Failed to connect to an IPC Port: Access is denied. Server stack trace: at System.Runtime.Remoting.Channels.Ipc.IpcPort.Connect(String portName, Boolean secure, TokenImpersonationLevel impersonationLevel, Int32 timeout) at System.Runtime.Remoting.Channels.Ipc.ConnectionCache.GetConnection(String portName, Boolean secure, TokenImpersonationLevel level, Int32 timeout) at System.Runtime.Remoting.Channels.Ipc.IpcClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream) at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.VisualStudio.TestTools.Agent.IAgentProcessManagerAccessManager.GetAgentProcessProxy(String executionKey) at Microsoft.VisualStudio.TestTools.Agent.AgentProcess.GetAgentProcessProxy()
I am executing the command using Invoke-Command using the same credentials used for RDP (in which session the command is successful). Also, in the Invoke-Command scriptblock, if I call whoami /priv, I see a response with 23 privilege names. Based on my previous research, this means I'm running in an elevated session. Invoke-Command is using Authentication = Negotiate.
I don't think that this is a firewall issue because I can run other commands from within the scriptblock successfully, just not mstest, so the PowerShell session is starting on the remote machine.
Note that this is detailed in this forum post but without resolution.