0

I have a custom PowerShell commandlet that I have created in C# that spins up some instances of vstest.console.exe and publishes the test results to a .trx file or to tfs. This commandlet works in isolation when using PowerShell locally.

However when I run the commandlet remotely using v3 PowerShell remoting, The invoke-command completes, but there are 2 issues:

  1. The test run process does not complete as there is no results file published
  2. I do not get the results on the remote console, whereas in the local case they bubble up from the newly started processes

Here is the remote call I used in the remote PowerShell calling script

$j = Invoke-Command -Session $currentPSSession -AsJob -ScriptBlock {
    Add-PSSnapin "IntegrationTestTools"
    Start-IntegrationTests -someotherUnimportantArgs
} | Wait-Job

$results = $j | Receive-Job

from stepping through the script it does indeed wait for the job, however the results are empty.

To note I have setup the remoting as per Keith Hill's post . Also I have setup Wsman with

set-item WSMan:\localhost\Shell\MaxMemoryPerShellMB 0
set-item WSMan:\localhost\Shell\MaxProcessesPerShell 0
set-item WSMan:\localhost\Shell\MaxShellsPerUser 0

So processes and allowed memory should not be limiting this particular exercise.

Any ideas?

4

1 回答 1

2

我想我会分享,以防有人不幸在某个时候发生这种情况。如果您在连接到远程 PowerShell 会话时使用 credssp 作为身份验证枚举,则您的用户令牌被标记为“模拟”,这意味着您是 NETWORK USER 组的一部分,这意味着 WCF 命名管道作为 SID 5-1 不可见-5-2(通常称为网络 SID)被拒绝访问命名管道。这是一篇关于该主题的启发性文章:KennyW 的博客

我从我的 PowerShell commandlet 远程启动的进程启动了通过命名管道进行通信的子进程:(
所以最后必须以psexec (sysinternals) 作为系统来让该进程在远程会话中本地执行。不优雅,但它是我所拥有的一切。

还要感谢Keith Hill在 PowerShell 故障排除方面的帮助!

我的博客文章详细介绍了我的发现 - http://josephkirwin.com/2013/05/06/the-named-pipes-had-a-party-and-imposters-were-not-invited/

于 2013-05-06T16:25:19.723 回答