From 77b6e4398d3fe692cbdbe05c59e459deec197ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0t=C4=9Bp=C3=A1n?= Date: Tue, 21 Jul 2026 15:25:01 +0200 Subject: [PATCH] Add Set-RoomMailboxPermission script to configure calendar permissions and processing settings for room mailboxes --- Set-RoomMailboxPermission.ps1 | 110 ++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 Set-RoomMailboxPermission.ps1 diff --git a/Set-RoomMailboxPermission.ps1 b/Set-RoomMailboxPermission.ps1 new file mode 100644 index 0000000..d1781f4 --- /dev/null +++ b/Set-RoomMailboxPermission.ps1 @@ -0,0 +1,110 @@ +<# +.SYNOPSIS + Configures calendar permissions and processing settings on the specified room mailboxes. + +.DESCRIPTION + For each mailbox identity supplied (directly or via the pipeline): + - Grants the Default user LimitedDetails access on the mailbox calendar + folder. + - Configures calendar processing so the organizer's name is added to the + meeting subject, and neither comments nor the subject are stripped + from booking requests. + + Requires an existing Exchange Online session (Connect-ExchangeOnline) - + this script does not connect or disconnect itself. + +.PARAMETER Identity + One or more room mailbox identities (UPN, email address, or Exchange + Identity) to configure. Accepts pipeline input, e.g. piped straight from + Get-Mailbox. + +.PARAMETER CalendarFolderName + Name of the mailbox's Calendar folder, in the mailbox's own language. + Defaults to "Calendar" (English). Use this for non-English mailboxes, e.g. + "Kalendar" for Czech. The actual name for a given mailbox can be listed + with: + Get-MailboxFolderStatistics -Identity -FolderScope Calendar | Where-Object { $_.FolderType -eq 'Calendar' } | Select-Object Name + +.EXAMPLE + .\Set-RoomMailboxPermission.ps1 -Identity room1@contoso.com + Configures a single room mailbox. + +.EXAMPLE + Get-Mailbox -ResultSize Unlimited | Where-Object { $_.ResourceType -eq 'Room' } | .\Set-RoomMailboxPermission.ps1 + Configures every room mailbox in the tenant, piped in from Get-Mailbox. + +.EXAMPLE + Get-Mailbox -ResultSize Unlimited | Where-Object { $_.ResourceType -eq 'Room' } | .\Set-RoomMailboxPermission.ps1 -WhatIf + Shows which room mailboxes would be changed without applying anything. + +.EXAMPLE + .\Set-RoomMailboxPermission.ps1 -Identity room-cz@contoso.com -CalendarFolderName 'Kalendar' + Configures a Czech-locale room mailbox whose Calendar folder is named "Kalendar". + +.NOTES + Author: Petr Stepan + Created: 2026-07-21 + Version: 1.0.0 + Changelog: + 1.0.0 - Initial version + + Requires the ExchangeOnlineManagement module, an active Exchange Online + session, and an account with permission to manage mailbox folder + permissions and calendar processing. +#> + +#Requires -Modules ExchangeOnlineManagement +[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] +param ( + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = 'Room mailbox identity (UPN, email, or Exchange Identity) to configure.')] + [ValidateNotNullOrEmpty()] + [string[]] + $Identity, + + [Parameter(Mandatory = $false, HelpMessage = 'Name of the Calendar folder in the mailbox locale.')] + [ValidateNotNullOrEmpty()] + [string] + $CalendarFolderName = 'Calendar' +) + +begin { + Set-StrictMode -Version Latest + $ErrorActionPreference = 'Stop' + + $processedCount = 0 + $failedCount = 0 +} + +process { + foreach ($id in $Identity) { + $processedCount++ + + if ($PSCmdlet.ShouldProcess($id, "Set calendar folder permission (LimitedDetails) and calendar processing settings")) { + try { + Set-MailboxFolderPermission -Identity "$($id):\$CalendarFolderName" -User Default -AccessRights LimitedDetails -ErrorAction Stop + + Set-CalendarProcessing -Identity $id -AddOrganizerToSubject $true -DeleteComments $false -DeleteSubject $false -ErrorAction Stop + + Write-Verbose "Configured '$id' successfully." + } + catch { + Write-Warning "Failed to configure '$id': $_" + $failedCount++ + } + } + } +} + +end { + if ($processedCount -eq 0) { + Write-Warning "No mailboxes were provided." + exit 0 + } + + if ($failedCount -gt 0) { + Write-Warning "$failedCount of $processedCount mailboxes failed to configure." + exit 1 + } + + exit 0 +}