Closed bigdavidwong closed 2 years ago
It's hard to tell what might be happening here but essentially the server is not responding to a request when getting the output back. It's receiving a read timeout after 120 seconds as per
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='test-mailbox02.mydomain.com', port=5985): Read timed out. (read timeout=120)
What is curious is that this is happening when the client is sending a WSMan Receive command which itself has an operation timeout of 20 seconds. The lower operation timeout here should be firing before the HTTP read timeout occurred which tells me the server is not even processing the read request. What this is I'm not sure but something critical has failed on the server.
Can you explain why you are using a nested prompt. This could be causing problems as there are now essentially 2 WSMan commands present on the remote host and something may not be working properly. Nested commands is not something I've really played with too much before.
Thanks for your reply!
Actually the core reason I used nested shell is: I want to handle multiple scripts in one connection, that will save lots of time especially when I have to import a session in powershell at first to process target scripts, and I found the nested shell can do this job when I was reading your code...
But now I've found a new way to solve this problem from issue https://github.com/jborean93/pypsrp/issues/106#issuecomment-845644289, I can create another PowerShell object from RunspacePool to handle multiple scripts in one connection, and the problem I got in nested shell will not happen in this way, this kind of shell always returned me the specific errors.
In conclusion, some kind of powershell errors could not be handled and returned in nested powershell, and in exactly the same situation, this problem will not occur in normal powershell.
At the end, since I've found a solution, please consider it a bug report~
Again, thanks for your reply and your excellent tools!
Glad you found a solution, using a Runspace Pool with multiple runspaces is definitely the preferred option over a nested pipeline to run things concurrently. Nested pipelines are definitely an edge case that I've never fully understood. I'll see if I can try and replicate this outside of Exchange as that adds another layer into the mix but ultimately I'm not sure if this is a bug or working as intended from a protocol perspective.
Hi Jordan,
At first, really thanks for your tools, it really helps me a lot!
Now I have some trouble when I am using it in exchange connections. If I want to create an email account which can not be created(account already existed or name already used by system), the powershell will not return the error info even it happened, and the only thing I can do is waiting, then get an bad http response;
here is my program steps:
New-Mailbox -UserPrincipalName network@mydomain.com -Name network -DisplayName testnetwork -OrganizationalUnit ExchangePublic -Password (ConvertTo-SecureString "Test!@#123" -AsPlainText -Force)
issue happened after step 6, and after a few minutes, I got some errors like this:
this kind of problem not just happened in Exchange, I remembered it also happened when I was using it to handle dns problem in my windows dns server, and I am really upset I forget what scripts I used when that happened;
looking forward to your reply!