Are you needing to track-down which mailboxes a user has access to?
Scenario #1
An employee might have been given access to multiple mailbox to temporarily handle additional workloads. Perhaps there was materny/paternal leave and someone is taking on the responsibility. The time arises when the user’s original access to certain mailboxes needs to be removed.
PowerShell Script
It’s straightforward and to the point to achieve this in Powershell. This script is essentially searching through each Exchange-Online mailbox and searching for the user defined. The results will be saved into a $ variable and display in a formatted table at the end.
##Searches all Mailboxes where user like UserName has full or read access rights##
Connect-ExchangeOnline
$results = @()
Get-Mailbox -ResultSize Unlimited | ForEach-Object {
$mailboxPermissions = Get-MailboxPermission -Identity $_.DistinguishedName | Where-Object {
($_.User -like "*[email protected]") -and (($_.AccessRights -like "*FullAccess*") -or ($_.AccessRights -like "*ReadPermission*"))
}
if ($mailboxPermissions) {
$upn = $_.UserPrincipalName
$result = [PSCustomObject]@{
Mailbox = $upn
AccessRights = $mailboxPermissions.AccessRights -join ', '
}
$results += $result
}
}
##Output results in a list format##
$results | Format-Table -AutoSize
✨ Feedback & Suggestions
If you have any suggestions/feedback, you can contact me via my email.