It wasn't that bad, right? And it's well-known knowledge that you can get when you ask Google for that. What I wanted to mention in this article is that depending on the language set on user mailbox setting LimitedDetails access right will most likely fail if it's anything then English. In my case, it's almost never English. So what do you do? Simple you use the language you expect on the mailbox!
See? Simple! Well not really. There are lots of languages out there and knowing which user, which mailbox has what language is hard to guess. Fortunately, there's a way to ask mailbox to give us that information so we don't have to guess and have a fully automated way to do that.
$Mailboxes = Get-Mailbox -RecipientTypeDetails RoomMailbox
$Count = 0
foreach ($Mailbox in $Mailboxes) {
$Count++
$Folder = Get-MailboxFolderStatistics -Identity $($Mailbox.UserPrincipalName) -FolderScope Calendar #-ErrorAction Stop
Write-Color "[", $Count, '/', $Mailboxes.Count, '] ', "Processing ", $Mailbox.UserPrincipalName -Color Yellow, White, Yellow, White, Yellow, White, Green
foreach ($F in $Folder) {
if ($F.FolderType -eq 'Calendar') {
$CalendarPath = $F.FolderPath -Replace '/', '\'
Set-MailboxFolderPermission -Identity "$($Mailbox.UserPrincipalName):$CalendarPath" -User Default -AccessRights LimitedDetails -ErrorAction SilentlyContinue -WhatIf
Set-CalendarProcessing -Identity $Mailbox.UserPrincipalName -AddOrganizerToSubject $true -DeleteComments $false -DeleteSubject $false -ErrorAction SilentlyContinue -WhatIf
Write-Color -Text "[", $Count, '/', $Mailboxes.Count, '] ', "Processed ", $Mailbox.UserPrincipalName, ' on folder type ', $F.FolderType, ' path ', $CalendarPath `
-Color Yellow, White, Yellow, White, Yellow, White, Yellow, White, Green
}
}
}
As you can see above, I'm merely getting all mailboxes and then for each mailbox I'm executing Get-MailboxFolderStatistics which happens to have FolderType available for each entry. This is always stored in English. So we use foreach to check for Calendar entry and use that folder as CalendarPath. Remember to change RecipientTypeDetails to any other type you may want to adjust settings for. Also, keep in mind that Set-CalendarProcessing may not be required in your scenario. You can apply the same approach to any other folder type to cover other needs. As you can see on the screenshot below folder names are in Swedish but FolderType stays in English. That way it's easy to apply that knowledge to other scenarios you may have.
Get-MailboxFolderStatistics -Identity $($Mailbox.UserPrincipalName) | Format-Table -AutoSize Name, FolderPath, FolderType, CreationTime, Date, LastModifiedTime
Keep in mind that the code above that fixes Calendar entries has FolderScope defined as Calendar. This means that only Calendar is returned. If you want to get all of it, simply skip that and you should be able to apply your changes to any type of folder you need.