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