Cancel and remove the calendar events for a mailbox in Exchange Online

Cancel and remove the calendar events for a mailbox in Exchange Online

Introduction

There might come a time when you need to cancel or remove the meetings and events from a mailbox. Maybe the user left the organization (and the mailbox is still around), or maybe someone has an unplanned leave of absence and you need to clean up the meetings they've sent. That's where this solution comes in handy.

Steps to remove the calendar events

So, in our example for today, the user Razvan has 4 calendar items:
Test Meetings.png

  • 1st meeting is a Regular meeting with participant
  • 2nd meeting is recurring (1 per week, what you see is the 1st occurrence)
  • 3rd meeting is just an appointment (no participants)
  • 4th meeting is one organized by someone else

For the sake of trying to include as many examples as possible, let's imagine we have to clear events from Thu (so, 1st and 2nd meeting will be impacted, but the 3rd and 4th should not be touched).

!NOTE: This is a destructive action! Deleting calendar events should be done with precaution.
Additional NOTE: You could.. in theory grant yourself Full Access permissions over the calendar in question, and you could go in and manually remove/delete the meetings you need to remove, but there are 2 problems with this approach:

  • Removing calendars by pressing "Delete" does not Cancel them, so other participants will still have copies. If you do it with the method I'm presenting, any meetings organized by Razvan will be truthfully canceled and cancellation messages properly sent to participants.
  • You might be tasked with deleting calendar events for multiple calendars for multiple months, and this then just becomes difficult to do manually with Full Access permissions.

So, how do we proceed to do this programatically? Of course - via PowerShell. We connect to the Exchange Module, then we use the cmdlet "Remove-CalendarEvents":

PreviewOnly.png

Appointment not removed.png

connect-exchangeonline

Remove-CalendarEvents -Identity Razvan@cloudpersistence.com -CancelOrganizedMeetings -QueryStartDate 07-31-2024 -QueryWindowInDays 5 -PreviewOnly -verbose

Notice I used the switches -PreviewOnly and Verbose to catch a glimpse of what might be removed. If we're satisfied with our query, we can remove those final switches.

We can also use

-QueryStartDate (Get-Date) to get the current date (meetings from now onwards). As for -QueryWindowInDays you can go 5 years into the future.

!NOTE: In my tests if there's any reccuring meeting occurrence cought in the deletion timeframe, all the series will be canceled, regardless if the 1st occurrence is way behind in the past relative to the QueryStartDate you configured

I'm happy with my selection, so let's remove the "-PreviewOnly" parameter at the end of the cmdlet, and re-run it:

Remove-CalendarEvents -Identity Razvan@cloudpersistence.com -CancelOrganizedMeetings -QueryStartDate 07-31-2024 -QueryWindowInDays 5 -Verbose

Deleted Meetings.png

And Voila, like magic they're gone!

Conclusion

Easy to use PowerShell one liner to Cancel meetings from an organizer's calendar. Especially useful with departed users that have booked meeting rooms or meetings in other people's calendars, or to remove some meetings during someone's absence. The only requirement is that the organizing mailbox is still around (maybe kept as a Shared mailbox?) since cancellation messages need to be sent.