문제

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?

도움이 되었습니까?

해결책

I thought I'd share in case anyone is unlucky enough to have this happen at some point. If you use credssp as authentication enum when connecting to a remote PowerShell session, your user token is marked as "impersonate", this means that you are part of the NETWORK USER group which means no visibility of WCF named pipes as the SID 5-1-5-2 (more commonly known as the Network SID) is denied access to named pipes. Here's an enlightening article on the subject: KennyW's blog.

The process I was remotely starting with my PowerShell commandlet started child processes that were communicating over named pipes :(
So in the end had to psexec (sysinternals) as system to get that process to execute locally within the remote session. Not elegant but it was all I had available.

Also thanks to Keith Hill for his help with the PowerShell troubleshooting!

My blog article detailing my findings - http://josephkirwin.com/2013/05/06/the-named-pipes-had-a-party-and-imposters-were-not-invited/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top