PowerShell

Changing Exchange folder permissions in multilanguage Office 365 tenants

One of the tasks I often get when setting up new Office 365 tenant or installing Exchange Servers is to change the visibility of Room Mailboxes or in some cases even standard users. There's nothing hard about it, and there are plenty of articles about it. It's just three simple steps.

Show meeting details of a Exchange (Office 365) room calendar
Connect to Microsoft Exchange / Microsoft Exchange Online
Set visibility of calendar from None to Limited Details for everyone

You just need to change Folder Permissions to Limited Details on Room:\Calendar using code below

Set-MailboxFolderPermission -AccessRights LimitedDetails -Identity Room:\calendar -User default
Show the Subject and Organiser

And if it's needed change how calendar processing is done on those Room Mailboxes. Depending on business requirements management may want to add an organizer to subject.

Set-CalendarProcessing -Identity Room -AddOrganizerToSubject $true -DeleteComments $false -DeleteSubject $false

By default, the subject is deleted, so depending on your requirement you need to set it to true or false. If you set your DeleteSubject to false only new meeting requests will be affected.  For existing meetings you will see the organizer and the location, new calendar entries will also have the subject displayed.

Show meeting details of a Exchange (Office 365) room calendar for other languages

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!

Set-MailboxFolderPermission -AccessRights LimitedDetails -Identity Room:\Kalendarz -User default

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.

This post was last modified on March 22, 2019 21:00

Przemyslaw Klys

System Architect with over 14 years of experience in the IT field. Skilled, among others, in Active Directory, Microsoft Exchange and Office 365. Profoundly interested in PowerShell. Software geek.

Share
Published by
Przemyslaw Klys

Recent Posts

Upgrade Azure Active Directory Connect fails with unexpected error

Today, I made the decision to upgrade my test environment and update the version of…

1 week ago

Mastering Active Directory Hygiene: Automating Stale Computer Cleanup with CleanupMonster

Have you ever looked at your Active Directory and wondered, "Why do I still have…

4 months ago

Active Directory Replication Summary to your Email or Microsoft Teams

Active Directory replication is a critical process that ensures the consistent and up-to-date state of…

8 months ago

Syncing Global Address List (GAL) to personal contacts and between Office 365 tenants with PowerShell

Hey there! Today, I wanted to introduce you to one of the small but excellent…

1 year ago

Active Directory Health Check using Microsoft Entra Connect Health Service

Active Directory (AD) is crucial in managing identities and resources within an organization. Ensuring its…

1 year ago

Seamless HTML Report Creation: Harness the Power of Markdown with PSWriteHTML PowerShell Module

In today's digital age, the ability to create compelling and informative HTML reports and documents…

1 year ago