Windows PowerShell Home
Random failures of Test-Path using Invoke-Command and double-hop remoting
4/4/2013 6:02:41 AM
User(s) can reproduce this bug
Environment: Powershell V3.0, WinRM 3.0 on Server 2012/2008 R2 domain network.
I've noticed failures in Test-Path in our application that may be related to double-hop but they are strangely random and related to timing/delays in execution.
I am running the script on System-1(server 2008), Remoting to System-2(server 2008) using Invoke-Command and then querying and accessing known files on System-3(server 2012). Test-Path fails randomly in this case. This attached file sample script loops an arbitrary 20 times since the problem occurs after some number of iterations of the loop. The problem goes away if you set the $fname variable to the local access file (local to System-2). The problem also goes away if you remove the intervening simple access to the file (dir $fname) !!! And if you wait seconds between running the script, the results vary.
I have set all WinRM settings to adjust for Maximum sessions/connections. I've read every blog and tried about anything I can think of. Credentials are fine. I have not tried this with WinRM 2.0.
The WinRM3.0 patch for Server 2008 is reported to be problematic - but due to the timing quirks it seems like remote sessions created by Invoke-Command are persistent and failures are occurring when I hit against the quota for connections.
How often does this happen?
Have you seen this problem before in this product?
I do not know if this issue existed previously
Demo loop (say 20 times) a call to Invoke-Command -ScriptBlock to a 2nd computer. Inside the script block use the (Test-Path -literalpath $fname) cmdlet followed by a simple access (dir $fname) where $fname is a known-to-exist file. If $fname is local to the 2nd computer - all works fine. If $fname is referenced to a 3rd computer it works sporadically. In the latter case, it can be made to work fully by removing the simple access (dir $fname) line.
Or Run the attached script:
- setup $cred as required to access systems used in the test
- assign computer names to System-2 and System-3
Test-Path should always work in this case !
to post a comment.
Please enter a comment.
to post a workaround.
Please enter a workaround.
© 2014 Microsoft