Skip to content

Optimize Test-MtCisSharedMailboxSignIn.ps1#1440

Open
ricmestre wants to merge 5 commits intomaester365:mainfrom
ricmestre:main
Open

Optimize Test-MtCisSharedMailboxSignIn.ps1#1440
ricmestre wants to merge 5 commits intomaester365:mainfrom
ricmestre:main

Conversation

@ricmestre
Copy link

Description

This optimizes Test-MtCisSharedMailboxSignIn.ps1 with the following:

  • Added EXOSharedMailbox command to Get-MtExo so that it retrieves only shared mailboxes with Get-EXOMailbox -RecipientTypeDetails 'SharedMailbox' instead of retrieving all mailboxes and filtering them locally
  • Retrieve the users associated with the shared mailbox using Graph batches instead of individually
  • Assign loop result to a variable instead of expanding an array on each pass

This PR also adds -ResultSize 'Unlimited' to both EXOMailbox and EXOSharedMailbox commands so that it actually retrieves all mailboxes instead of bumping into a limit so this also should fix an issue:

Contribution Checklist

Before submitting this PR, please confirm you have completed the following:

  • 📖 Read the guidelines for contributing to this repository.
  • 🧪 Ensure the build and unit tests pass by running /powershell/tests/pester.ps1 on your local system.

 

Join us at the Maester repository discussions 💬 or Entra Discord 🧑‍💻 for more help and conversations!

@ricmestre ricmestre requested review from a team as code owners February 14, 2026 13:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes the Test-MtCisSharedMailboxSignIn function to improve performance and fix issue #1417 where shared mailboxes weren't being retrieved in large tenants. The optimization introduces a new EXOSharedMailbox command to Get-MtExo that retrieves only shared mailboxes directly from Exchange, adds -ResultSize 'Unlimited' to prevent pagination limits, and uses Graph API batching to retrieve user information efficiently instead of individual requests.

Changes:

  • Added -ResultSize 'Unlimited' to EXOMailbox command in Get-MtExo to retrieve all mailboxes without pagination limits
  • Added new EXOSharedMailbox command to Get-MtExo that filters for shared mailboxes at the Exchange level
  • Replaced individual Graph API calls in a loop with batched Graph request using array of IDs for better performance

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
powershell/public/cisa/exchange/Get-MtExo.ps1 Added -ResultSize 'Unlimited' to EXOMailbox command and created new EXOSharedMailbox command for filtered retrieval
powershell/public/cis/Test-MtCisSharedMailboxSignIn.ps1 Updated to use new EXOSharedMailbox command and implemented Graph batching for user retrieval

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Successfully merging this pull request may close these issues.

🪲 Get-MtExo not retrieving shared mailboxes

1 participant

Comments