Forum Discussion
C# + PowerShell + Linux AKS - Cmdlet results in failure, but action executed
- Oct 05, 2023
Hi 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:
- A problem with the PowerShell script itself
- A problem with the PowerShell session
- A problem with the underlying operating system
- A problem with the network connection
- A problem with the Exchange Online service
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:
- Create a new runspace for each command.
- Use the Invoke-Command cmdlet to run each command in a separate PowerShell session.
- Use the Try-Catch block to catch any errors that occur and handle them accordingly.
You can also try the following:
- Increase the Timeout parameter of the Invoke-Command cmdlet.
- Increase the MaxIdleTime parameter of the PSCredential object.
- Try using a different PowerShell version.
- Try using a different Exchange Online PowerShell module.
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)
Hi 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:
- A problem with the PowerShell script itself
- A problem with the PowerShell session
- A problem with the underlying operating system
- A problem with the network connection
- A problem with the Exchange Online service
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:
- Create a new runspace for each command.
- Use the Invoke-Command cmdlet to run each command in a separate PowerShell session.
- Use the Try-Catch block to catch any errors that occur and handle them accordingly.
You can also try the following:
- Increase the Timeout parameter of the Invoke-Command cmdlet.
- Increase the MaxIdleTime parameter of the PSCredential object.
- Try using a different PowerShell version.
- Try using a different Exchange Online PowerShell module.
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)
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