Skip to content

Commit 29a7044

Browse files
committed
fix: Correct anchor mailbox for Get-MailboxCalendarConfiguration
Optimize mailbox, place, and calendar property updates in Invoke-EditRoomMailbox and Invoke-ListRooms functions
1 parent a0872fe commit 29a7044

2 files changed

Lines changed: 35 additions & 44 deletions

File tree

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Resources/Invoke-EditRoomMailbox.ps1

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,17 @@ Function Invoke-EditRoomMailbox {
8585
}
8686

8787
try {
88-
# Update mailbox properties
89-
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'Set-Mailbox' -cmdParams $UpdateMailboxParams
90-
91-
# Update place properties
92-
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'Set-Place' -cmdParams $UpdatePlaceParams
93-
$Results.Add("Successfully updated room: $($MailboxObject.DisplayName) (Place Properties)")
94-
95-
# Update calendar properties
96-
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'Set-CalendarProcessing' -cmdParams $UpdateCalendarParams
97-
$Results.Add("Successfully updated room: $($MailboxObject.DisplayName) (Calendar Properties)")
98-
99-
# Update calendar configuration properties
100-
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'Set-MailboxCalendarConfiguration' -cmdParams $UpdateCalendarConfigParams
88+
# Batch mailbox, place, and calendar processing together
89+
$BulkBatch = @(
90+
@{ CmdletInput = @{ CmdletName = 'Set-Mailbox'; Parameters = $UpdateMailboxParams } }
91+
@{ CmdletInput = @{ CmdletName = 'Set-Place'; Parameters = $UpdatePlaceParams } }
92+
@{ CmdletInput = @{ CmdletName = 'Set-CalendarProcessing'; Parameters = $UpdateCalendarParams } }
93+
)
94+
$null = New-ExoBulkRequest -tenantid $Tenant -cmdletArray $BulkBatch
95+
$Results.Add("Successfully updated room: $($MailboxObject.DisplayName) (Mailbox, Place & Calendar Properties)")
96+
97+
# Set-MailboxCalendarConfiguration requires anchor to the room mailbox
98+
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'Set-MailboxCalendarConfiguration' -cmdParams $UpdateCalendarConfigParams -Anchor $MailboxObject.roomId
10199
$Results.Add("Successfully updated room: $($MailboxObject.DisplayName) (Calendar Configuration)")
102100

103101
Write-LogMessage -headers $Request.Headers -API $APIName -tenant $Tenant -message "Updated room $($MailboxObject.DisplayName)" -Sev 'Info'

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Resources/Invoke-ListRooms.ps1

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function Invoke-ListRooms {
1+
function Invoke-ListRooms {
22
<#
33
.FUNCTIONALITY
44
Entrypoint
@@ -14,26 +14,20 @@ Function Invoke-ListRooms {
1414
# I dont like that i had to change it to EXO commands, but the waiting time for the Rooms to sync to Graph is too long :( -Bobby
1515
try {
1616
if ($RoomId) {
17-
# Get specific room mailbox
18-
$RoomMailbox = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-Mailbox' -cmdParams @{
19-
Identity = $RoomId
20-
RecipientTypeDetails = 'RoomMailbox'
21-
} | Select-Object -ExcludeProperty *@odata.type*
22-
23-
# Get place details
24-
$PlaceDetails = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-Place' -cmdParams @{
25-
Identity = $RoomId
26-
} | Select-Object -ExcludeProperty *@odata.type*
27-
28-
# Get calendar properties
29-
$CalendarProperties = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-CalendarProcessing' -cmdParams @{
30-
Identity = $RoomId
31-
} | Select-Object -ExcludeProperty *@odata.type*
32-
33-
# Get calendar properties
34-
$CalendarConfigurationProperties = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-MailboxCalendarConfiguration' -cmdParams @{
35-
Identity = $RoomId
36-
} | Select-Object -ExcludeProperty *@odata.type*
17+
# Batch mailbox, place, and calendar processing together
18+
$BulkBatch = @(
19+
@{ CmdletInput = @{ CmdletName = 'Get-Mailbox'; Parameters = @{ Identity = $RoomId; RecipientTypeDetails = 'RoomMailbox' } } }
20+
@{ CmdletInput = @{ CmdletName = 'Get-Place'; Parameters = @{ Identity = $RoomId } } }
21+
@{ CmdletInput = @{ CmdletName = 'Get-CalendarProcessing'; Parameters = @{ Identity = $RoomId } } }
22+
)
23+
$BulkResults = New-ExoBulkRequest -tenantid $TenantFilter -cmdletArray $BulkBatch -ReturnWithCommand $true
24+
25+
$RoomMailbox = $BulkResults['Get-Mailbox'] | Select-Object -ExcludeProperty *@odata.type* | Select-Object -First 1
26+
$PlaceDetails = $BulkResults['Get-Place'] | Select-Object -ExcludeProperty *@odata.type* | Select-Object -First 1
27+
$CalendarProperties = $BulkResults['Get-CalendarProcessing'] | Select-Object -ExcludeProperty *@odata.type* | Select-Object -First 1
28+
29+
# Get-MailboxCalendarConfiguration requires anchor to the room mailbox
30+
$CalendarConfigurationProperties = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-MailboxCalendarConfiguration' -cmdParams @{ Identity = $RoomId } -Anchor $RoomId | Select-Object -ExcludeProperty *@odata.type*
3731

3832
if ($RoomMailbox -and $PlaceDetails -and $CalendarProperties -and $CalendarConfigurationProperties) {
3933
$GraphRequest = @(
@@ -97,16 +91,15 @@ Function Invoke-ListRooms {
9791
)
9892
}
9993
} else {
100-
# Get all room mailboxes in one call
101-
$RoomMailboxes = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-Mailbox' -cmdParams @{
102-
RecipientTypeDetails = 'RoomMailbox'
103-
ResultSize = 'Unlimited'
104-
} | Select-Object -ExcludeProperty *@odata.type*
105-
106-
# Get all places in one call
107-
$Places = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-Place' -cmdParams @{
108-
ResultSize = 'Unlimited'
109-
} | Select-Object -ExcludeProperty *@odata.type*
94+
# Batch Get-Mailbox and Get-Place into one request
95+
$CmdletArray = @(
96+
@{ CmdletInput = @{ CmdletName = 'Get-Mailbox'; Parameters = @{ RecipientTypeDetails = 'RoomMailbox'; ResultSize = 'Unlimited' } } }
97+
@{ CmdletInput = @{ CmdletName = 'Get-Place'; Parameters = @{ ResultSize = 'Unlimited' } } }
98+
)
99+
$BulkResults = New-ExoBulkRequest -tenantid $TenantFilter -cmdletArray $CmdletArray -ReturnWithCommand $true
100+
101+
$RoomMailboxes = $BulkResults['Get-Mailbox'] | Select-Object -ExcludeProperty *@odata.type*
102+
$Places = $BulkResults['Get-Place'] | Select-Object -ExcludeProperty *@odata.type*
110103

111104
# Create hashtable for quick place lookups
112105
$PlacesLookup = @{}

0 commit comments

Comments
 (0)