Oct 05 2023 12:08 AM
Our code is in C# and we use .NET7 & PowerShell SDK 7.3.6 & have this application deployed in AKS. The Docker image is based on aspnet:7.0-apline image with PowerShell 7 installed & PSWSMan, WSMan and ExchangeOnlineManagement (v3) modules installed.
We use an enterprise application connecting to Exchange Online via certificate authentication. We limit the commands to retrieve into the PowerShell session to New-Mailbox cmdlet only. Each command gets its own PS session reusing previously constructed runspace.
When we try to restore a previously deleted mailbox, we occasionally receive PSRemotingTransportException. The details we observe there are:
ErrorCode: 2101
CategoryInfo.Category: ResourceUnavailable
CategoryInfo.Reason: ParentContainsErrorRecordException
Exception message: The background process closed or ended abnormally: \n Exit code: 137\n Stdout: ''\n Stderr: ''\n .
When we execute this with multiple users at the same time (15 users, ~3 in parallel) - we receive such error 1-3 times out of whole batch of 15 mailboxes.
The issue is not on failure - because we can handle it. The main problem is that those users/mailboxes are actually (almost always) created, but the PowerShell connection is "interrupted" or something indicating there was an error and we need to go through additional steps.
Has anyone observed anything similar? Is there any reason for such error on our side? Is there anything we could try to get this more robust? Does anyone an idea on what the 2101 error stands for?
Oct 05 2023 05:49 AM
SolutionHi @MijeQsft,
he 2101 error code in PowerShell is a generic error that indicates that the background process closed or ended abnormally. This can be caused by a variety of factors, including:
In your case, it is likely that the error is being caused by a problem with the PowerShell session. This is because you are reusing the same runspace for each command. When you do this, any errors that occur in one command can be carried over to subsequent commands.
To try to resolve this issue, you can try the following:
You can also try the following:
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)
Oct 06 2023 05:54 AM
Hi @LeonPavesic,
thanks for the detailed writeup. This was actually very helpful in revisiting our approach.
We do have couple of ideas now (thanks to you) on how to address this and going to test them out. I will post an update if we have this fixed to our liking. We still expect it to fail, but maybe we can change the way we handle it gracefully for our consumers.
Best regards,
Michal
Oct 05 2023 05:49 AM
SolutionHi @MijeQsft,
he 2101 error code in PowerShell is a generic error that indicates that the background process closed or ended abnormally. This can be caused by a variety of factors, including:
In your case, it is likely that the error is being caused by a problem with the PowerShell session. This is because you are reusing the same runspace for each command. When you do this, any errors that occur in one command can be carried over to subsequent commands.
To try to resolve this issue, you can try the following:
You can also try the following:
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)