Recently, here at Tech With a Hammer, one of our technicians was hammering away at a mailbox in Office365, only to find permissions from Set-MailboxPermission still did not grant a user access to the subfolders of the mailbox. In this hammer we will provide you a script that can be used to perform a shotgun approach at fixing permissions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$mailbox = "End User 56293476" $user = "justanotheradmin@techwithahammer.com" $accessrights = "owner" $folders = Get-MailboxFolderStatistics $mailbox | ? {$_.FolderType -ne “Root” -and $_.FolderType -ne “Recoverableitemsroot” -and $_.FolderType -ne “Audits” -and $_.FolderType -ne “CalendarLogging” -and $_.FolderType -ne “RecoverableItemsDeletions” -and $_.FolderType -ne “RecoverableItemspurges” -and $_.FolderType -ne “RecoverableItemsversions”} Add-MailboxFolderPermission -Identity "$mailbox`:\" -User $user -AccessRights $accessrights foreach ($folder in $folders) { $FolderPath = $folder.FolderPath.Replace("/","\").Replace([char]63743,"/") #with PowerShell v3 'fix' $MailboxFolder = "$mailbox`:$FolderPath" Write-Host $MailboxFolder Add-MailboxFolderPermission -Identity "$MailboxFolder" -User $user -AccessRights $accessrights } |
See also adjusted $folders = and adjusted loop in https://social.technet.microsoft.com/Forums/office/en-US/acc18482-baaa-4fc8-9e11-2713d1897fbd/shared-mailbox-permissions?forum=exchangesvradmin&prof=required
Johan, we like the change you implemented for the change in permissions on the calendar, glad you were able to utilize this cmdlet and expand it!
In both on-prem Exchange and Office365 we have seen people mess up the Root folder permissions using scripts similar to this, which is the main reason we kept it out when transposing the script.