Cleaning up Microsoft 365 events from deleted users
When an employee leaves the organisation and their Microsoft 365 account is deleted, any meetings they organised, especially in room/resource calendars—do not get automatically removed. This can result in orphaned bookings that block room availability.
This article explains two methods to clean up such bookings depending on the mailbox status.
Method 1: Using Remove-CalendarEvents (preferred for active or recently deleted mailboxes)
Remove-CalendarEvents (preferred for active or recently deleted mailboxes)This method cancels all future meetings organised by the user and notifies attendees, including room mailboxes. It only works if:
The mailbox is still active or within the 30-day soft-delete retention period.
You have Exchange Administrator privileges.
🔧 Steps
Connect via Powershell to Exchange Online:
Connect-ExchangeOnlinePreview Future Meetings:
Remove-CalendarEvents -Identity [email protected] ` -CancelOrganizedMeetings ` -QueryWindowInDays 180 ` -PreviewOnlyReplace
[email protected]with the actual user email. The-PreviewOnlyflag lets you verify what will be removed. You can increase-QueryWindowInDaysup to 1080 to cover longer ranges.Execute Cleanup (after confirming preview):
Remove-CalendarEvents -Identity [email protected] ` -CancelOrganizedMeetings ` -QueryWindowInDays 180
Method 2: Using compliance search (for permanently deleted mailboxes)
If the user’s mailbox is permanently deleted (past 30 days), use Microsoft Purview (Compliance Center) to search and hard-delete meetings from resource mailboxes. This method does not notify attendees.
Requirements:
Compliance Administrator or eDiscovery Manager role.
A list of resource mailbox names.
🔧 Steps
Connect to Exchange Online & Compliance Center:
Connect-ExchangeOnline Connect-IPPSSessionCreate and Start the Search:
$Search = New-ComplianceSearch -Name "PurgeExUserMeetings" ` -ContentMatchQuery 'Organizer:"[email protected]"' ` -ExchangeLocation "[email protected]","[email protected]" Start-ComplianceSearch -Identity $Search.Identity Wait-ComplianceSearch -Identity $Search.NamePurge the Found Meetings:
New-ComplianceSearchAction -SearchName $Search.Name -Purge -PurgeType HardDelete🔍 Replace email and room addresses as needed. Use
Get-Mailbox -RecipientTypeDetails RoomMailboxto get resource mailbox names.
It is advisable to run Remove-CalendarEvents before deleting users.
Last updated
Was this helpful?