Quick and Easy Exchange Online Mailbox Permissions Report

Over the years, I’ve built up a library of handy PowerShell scripts which I am reviewing now to update for different additional functionalities and see where I can improve them. While doing that, I thought I’d share some of them.

I’ve updated this script to use the new,  faster, Graph based EXO cmdlets. The script will return a list of all mailboxes and permissions assigned to each. It gives a nice tidy email reference of both the mailbox and the delegate and a summary of all permissions assigned.

It’s a pretty simple PowerShell script but comes in handy more than you’d think as a quick reference when assessing permissions, particularly during a migration.

#Retrieve all mailboxes
$mailboxes = get-Exomailbox -ResultSize unlimited
#Loop through mailboxes
foreach($mailbox in $mailboxes){
    
    #Get Mailbox Permissions
    $Permissions = Get-EXOMailboxPermission $mailbox.primarysmtpaddress
    #Loop Through Permission set
    foreach($permission in $permissions){
    #Build Object
    $object = [pscustomobject]@{
                'UserEmail' = $permission.user
                'MailboxEmail' = $mailbox.primarysmtpaddress
                'PermissionSet' = [String]$permission.accessrights
                }
    
    #Export Details
    $Object | export-csv MailboxPermissions.csv -NoClobber -NoTypeInformation -Append 
    #Remove Object
    Remove-Variable object
    }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s