Forum Discussion
MS Bookings
AFAIK, there is no single Graph endpoint today that gives you “last activity” for all Microsoft Bookings calendars tenant-wide, but I believe you can get very close with a Graph + PowerShell approach that can be used for cleanup.
If I read your post correctly, you want to enumerate all Bookings in the tenant and then query appointments in the last 90 days and then flag those with zero activity as candidates for decommissioning.
I think this should do what you want:
Connect-MgGraph -Scopes "Bookings.Read.All","User.Read.All"
$businesses = Get-MgBookingBusiness -All
$cutoff = (Get-Date).AddDays(-90)
$results = foreach ($biz in $businesses) {
try {
$appointments = Get-MgBookingBusinessAppointment `
-BookingBusinessId $biz.Id `
-Filter "start/dateTime ge '$($cutoff.ToString("yyyy-MM-ddTHH:mm:ssZ"))'" `
-Top 1
[PSCustomObject]@{
BusinessName = $biz.DisplayName
BusinessEmail = $biz.Email
Created = $biz.CreatedDateTime
HasActivity = ($appointments.Count -gt 0)
}
}
catch {
# Orphaned and test businesses will likely error
[PSCustomObject]@{
BusinessName = $biz.DisplayName
BusinessEmail = $biz.Email
Created = $biz.CreatedDateTime
HasActivity = $false
}
}
}
$resultsYou might also want to check the shared mailboxes used by Bookings, which can also be an indicator of activity. This script can help you do that.
Connect-ExchangeOnline
Get-Mailbox -RecipientTypeDetails SharedMailbox | Where-Object {$_.DisplayName -like "*Bookings*"} | Get-MailboxStatistics | Select DisplayName, LastLogonTimeNo appointments + no mailbox logon in 90 days is a strong candidate for decommission. If the mailbox is active but there are no appointments, you can review it manually.
Hope this helps!