Know who has full mailbox permission for all the mailbox in your orgnaziation - Office 365

Get permission of all the mailbox (shared, Room, equipment)

In Office 365 when you get Full mailbox permission of a user accounts it return the SAM account name which is an unfamiliar name and it was hard to identify who is having permission on the mailbox.
This script gets the mailbox permission and converts the SAM account name to User's display name.
Copy the Code below to text file and save as PS1.
######################################
#author = Sunil Chauhan
#Email-ID = sunilkms@gmail.com
#Last modified : 1st July 2013
######################################
cls
"

starting..."

start-sleep 1

#-Getting All mailbox ----------

"

Fetching mailbox data..."

$mbx= Get-mailbox -resultsize Unlimited

"

Mailbox data fetched"

start-sleep 1

#----Getting Mailbox Permission---

"

Getting mailbox Permission..."

#-Setting counters-----
$c = 0
$b = 0

#---Get Permisison block.
$mbxlist= foreach ($usr in $mbx)
{

$b++

Write-host " Checking rights for User $b = $usr ";

Get-MailboxPermission $usr.alias | ? {$_.isinherited -ne "True" -and $_.User -notlike "S-1-5*" -and $_.user -notlike "*Self"} | select Identity,

user, AccessRights,@{Label="RecipientType";Expression={$mbx[$c] | Select RecipientTypeDetails}}

$c++

}
#----Converting SAM account to User display Name
Write-host "Converting Sam account to User Displayname" -f cyan;

"

Please wait it may take sevral minuts...."

$FinalReport=$mbxlist | select Identity, `
@{Label="User";Expression={Write-host "Converting for $_"(get-user $_.User).Name}}, accessrights, RecipientType

#-Exporting data to file
$csv = "FullMailboxRightReportAll.csv"
$finalReport | Export-CSV $csv -notype
Write-host " Reporting Completed, Data exported to $csv" -f Green

Comments