I have a script that will pull permissions for all Exchange mailboxes for the calendar folder. This works quite well for just the calendar folders. However, I need to search all folders (not just default folders) for all mailboxes in my environment. I know it will be an intense script. Bottom line we are attempting to clean up our distribution lists that are set to security objects and need to know where someone has granted permissions to a security group.
FYI...I did search the archives for folder permissions and only got 10 hits. I am fairly new to PowerShell scripting so I apologize for my ignorance but would greatly appreciate any assistance you can provide.
# Get the mailboxes $Mailboxes = Get-Mailbox -Filter {RecipientTypeDetails -eq "UserMailbox"} -ResultSize unlimited # An array for the output $Output = @() # Loop through the mailboxes ForEach ($Mailbox in $Mailboxes) { # Get the name of the calendar folder $Calendar = (($Mailbox.PrimarySmtpAddress.ToString())+ ":\" + (Get-MailboxFolderStatistics -Identity $Mailbox.DistinguishedName -FolderScope Calendar | Select-Object -First 1).Name) # Get the permissions on the folder $Permissions = Get-MailboxFolderPermission -Identity $Calendar # Loop through the permissions, populating the output array ForEach ($Permission in $Permissions) { $Permission | Add-Member -MemberType NoteProperty -Name "Mailbox" -value $Mailbox.DisplayName $Output = $Output + $Permission } } # Write the output to a CSV file $Output | Select-Object Mailbox, User, {$_.AccessRights}, IsValid | Export-Csv -Path e:\_logs\CalendarPermissions.csv -NoTypeInformation