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)

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

  1. Connect via Powershell to Exchange Online:

    Connect-ExchangeOnline
  2. Preview Future Meetings:

    Remove-CalendarEvents -Identity [email protected] `
      -CancelOrganizedMeetings `
      -QueryWindowInDays 180 `
      -PreviewOnly

    Replace [email protected] with the actual user email. The -PreviewOnly flag lets you verify what will be removed. You can increase -QueryWindowInDays up to 1080 to cover longer ranges.

  3. 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

  1. Connect to Exchange Online & Compliance Center:

    Connect-ExchangeOnline
    Connect-IPPSSession
  2. Create 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.Name
  3. Purge the Found Meetings:

    New-ComplianceSearchAction -SearchName $Search.Name -Purge -PurgeType HardDelete

    🔍 Replace email and room addresses as needed. Use Get-Mailbox -RecipientTypeDetails RoomMailbox to get resource mailbox names.

Last updated

Was this helpful?