Create a CSV of mailbox delegate permissions to a mailbox

Scenario: You want to find who has delegate permissions to a mailbox and export the users, folders, and access permissions to a CSV File.

Run the following:

$AllUsers = get-mailbox  test*

ForEach ($Alias in $AllUsers)
 {
 $Mailbox = “” + $Alias.Name
 Write-Host “Getting folders for mailbox: ” $Mailbox
 $Folders = Get-MailboxFolderStatistics $Mailbox | % {$_.folderpath} | % {$_.replace(“/”,””)}

 $list = ForEach ($F in $Folders)
  {
  $FolderKey = $Mailbox + “:” + $F
  $Permissions = Get-MailboxFolderPermission -identity $FolderKey -ErrorAction SilentlyContinue
  $Permissions | Where-Object {$_.User -notlike “Default” -and $_.User -notlike “Anonymous” -and $_.AccessRights -notlike “None” -and $_.AccessRights -notlike  “Owner” }| Select $Mailbox, User, FolderName, AccessRights, *path*
  }
 }

$list | Export-csv C:delegates.csv

Reference: This code is edited from the original

One thought on “Create a CSV of mailbox delegate permissions to a mailbox”

Leave a comment