Entra / Microsoft 365 · Exchange Online
Report room mailbox usage summary
A very simple script to show how to detect whether room mailboxes are being used.
Connect & set up
Run these once per session. All scopes are read-only unless the script makes changes.
Connect-ExchangeOnlineConnect-MgGraph -AppId $AppId -TenantId $TenantId -CertificateThumbprint $CertThumbprint
Run it
The main script. Copy it, or download the .ps1 and run it from your console.
param([string] $TenantId = "",[string] $AppId = "",[string] $CertThumbPrint = "",[string] $StartDate = (Get-Date).AddMonths(-6),[string] $EndDate = (Get-Date).AddMonths(6))$CertThumbprint = '0CF6CE3F3548FD73E7AC8CF20226ED447E125C71'# Connect to Exchange Online and then to the Graph using app-only modeConnect-ExchangeOnlineConnect-MgGraph -AppId $AppId -TenantId $TenantId -CertificateThumbprint $CertThumbprint# Use Exchange Online to Find Mailboxes[array]$RoomMailboxes = Get-ExoMailbox -RecipientTypeDetails RoomMailbox -ResultSize Unlimited# Set date range to check forForEach ($RoomMailbox in $RoomMailboxes) {Try {Write-Host ("Getting calendar events for room mailbox {0}..." -f $RoomMailbox.DisplayName)[array]$Events = Get-MgUserCalendarView -UserId $RoomMailbox.PrimarySmtpAddress -All -StartDateTime $StartDate -EndDateTime $EndDate -ErrorAction Stop} Catch {Write-Host ("Couldn't get calendar events for room mailbox {0} - check the error message" -f $RoomMailbox.DisplayName)}If ($Events) {Write-Host ("{0} events found for {1}" -f $Events.count, $RoomMailbox.DisplayName)}}
Parameters
ParameterDefaultNotes
-TenantId""Microsoft Entra tenant ID for app-only Graph authentication.-AppId""Application (client) ID for the app registration used to connect.-CertThumbPrint""Certificate thumbprint for app-only Graph authentication.-StartDate(Get-Date).AddMonths(-6)Start of the reporting window.-EndDate(Get-Date).AddMonths(6)End of the reporting window.Attribution
Author
Office365itpros