Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Exchange sessions causes error message #102

Open
2 tasks
cferony opened this issue Jul 1, 2021 · 1 comment
Open
2 tasks

Multiple Exchange sessions causes error message #102

cferony opened this issue Jul 1, 2021 · 1 comment

Comments

@cferony
Copy link

cferony commented Jul 1, 2021

Thank you for reporting an issue, making a suggestion, or asking a question. We appreciate your feedback - to help the team understand your
needs please complete the below template to ensure we have the details to respond. Thanks!

Category

  • Suggested sample, script, or tool
  • [ X] Bug in existing sample, script, or tool
  • Question / Feedback

Issue Details

The Find-DelegateMailboxes.ps1 script throws an error when multiple Exchange sessions exist in the same shell session.

Bug in existing sample, script, or tool

Running the Find-DelegateMailboxes.ps1 script, I encountered an error upon initial execution. The error I received indicated that the Get-exchangeserver cmdlet could not accept an array as a parameter. See attached screenshot of the error.

ErrorMsg

### Expected / Desired Behavior The expected behavior is that the error message is not generated.

Observed Behavior

The observed behavior is that the error is generated when multiple Exchange sessions exist in the same shell session. I was able to determine that the line of code that causes the error is line number 845 ($exchangeversion = get-exchangeserver $exchserversession | select -expandproperty AdminDisplayVersion).

Steps to Reproduce

Open a PowerShell session and then establish multiple sessions to Exchange where the configuration name of the session is Microsoft.Exchange. For example, open a PowerShell session and establish a remote session to an Exchange 2016 server and then in the same PowerShell session open another remote session to Exchange Online. Ensure that both sessions have a configuration name of Microsoft.Exchange. then run the Find-DelegateMailboxes.ps1 script and you will see the error.

To resolve this issue a slight tweak to line 844 should be all that is needed. Line 844 should be updated as such:
$exchserversession = get-pssession | ?{$.configurationname -eq "Microsoft.Exchange" -and $.state -eq "Opened" } | select -expandproperty computername

Please see additional screenshot of a PowerShell session with multiple Exchange sessions opened where the ConfigurationName attribute is set to Microsoft.Exchange. In this instance my previously established session was broken (due to a network outage) and a new session was created when I attempted to run a new cmdlet.
MultipleSessions

@soyalejolopez
Copy link
Member

Thank you @cferony for your feedback and suggestion - if you don't mind, would you create a pull request? Glad to merge accordingly. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants