A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.
You could try with the script below to check permission for shared mailboxes, room mailboxes, user mailboxes (There doesn't exist full access permission for distribution group):
$mailboxes = Get-Mailbox -ResultSize unlimited | where{$_.RecipientTypeDetails -ne "DiscoveryMailbox"}
foreach ($mailbox in $mailboxes){
Get-MailboxPermission -Identity $mailbox.UserPrincipalName | where{$_.user -notlike "*self*"}
}
If it still takes a long time to run which caused failure, you could check permission based on domain:
$mailboxes = Get-Mailbox -ResultSize unlimited | where{$_.RecipientTypeDetails -ne "DiscoveryMailbox" -and $_.UserPrincipalName -like "*@domain.onmicrosoft.com"}
foreach ($mailbox in $mailboxes){
Get-MailboxPermission -Identity $mailbox.UserPrincipalName | where{$_.user -notlike "*self*"}
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
]