CRT
CRT copied to clipboard
Get-EXOMailbox performance
Hi CrowdStrike,
Cool script, but poor performance with big Office365 environments. Say, the following commands are specified: SMTPForward, FullAccessGranted, AnyAccessGranted, SendAsGranted together. This means script will run
Get-EXOMailbox -ResultSize Unlimited -ErrorAction SilentlyContinue | Get-EXORecipientPermission -ErrorAction Stop 4 times. This works well with small number of mailboxes, but a single execution of this command on, say, 50000 mailboxes will take a few days (believe me) to complete (eventually Microsoft will throttle you and slow down the requests). Your script calls it 4 times which will easily take more than a week (not counting possible auth session expiration when you'll need to restart the script).
My proposal would be first to save mailboxes to a variable like $mailboxes = Get-EXOMailbox -ResultSize Unlimited -ErrorAction SilentlyContinue and same for $permissions = $mailboxes | Get-EXORecipientPermission -ErrorAction Stop and reuse both $mailboxes and $permissions where possible. Let me know if I can contribute to the project!
Hi @vradchenko, thank you for your input. That sounds like a great idea, to be honest. You're welcome to contribute to the tool and I can review any modifications prior to publishing. Any other feedback for improving performance is welcome.