How to Use Remove-CalendarEvents in Powershell

How to Use Remove-CalendarEvents in Powershell

When managing a busy organization, keeping calendars clean and organized can be a daunting task, especially when team members leave or roles change.

We have a solution for this: the Remove-CalendarEvents cmdlet. This command in PowerShell is a handy tool for administrators looking to streamline this process, allowing you to efficiently remove meetings from a user’s calendar, particularly those that have attendees or reserved resources, ensuring that your team’s schedules stay up-to-date and free from unnecessary clutter.

Let’s go over how to use Remove-CalendarEvents in three simple steps!

What is the Remove Calendar Events Command?

Remove-CalendarEvents is a PowerShell cmdlet designed to help administrators manage and clean up user calendars in Microsoft Exchange and Office 365 environments, particularly in scenarios such as employee departures, account deprovisioning, or removal of obsolete meetings.

When executed, this cmdlet allows admins to target specific user mailboxes and remove calendar events within a defined date range, ensuring that meeting invitations, appointments, or recurring events created by a user are deleted across the organization. This is useful for avoiding orphaned meetings where the organizer is no longer with the company.

Here’s the syntax of Remove-CalendarEvents, including a short explanation for each one of the parameters you need to know in order to efficiently use this command:

Remove-CalendarEvents

[-Identity] <MailboxIdParameter>

-QueryWindowInDays <Int32>

[-CancelOrganizedMeetings]

[-Confirm]

[-PreviewOnly]

[-QueryStartDate <ExDateTime>]

[-UseCustomRouting]

[-WhatIf]

[<CommonParameters>]

  • Identity: Specifies the mailbox (user) from which the calendar events will be removed.
  • QueryWindowInDays: Defines the number of days, starting from the current date, within which to search for and remove calendar events.
  • CancelOrganizedMeetings: Cancels only the meetings organized by the specified mailbox that have attendees or resources.
  • Confirm: Prompts for confirmation before executing the cmdlet, ensuring the action is deliberate.
  • PreviewOnly: Shows what would happen if the cmdlet is run, without actually making any changes.
  • QueryStartDate: Specifies the start date for the range in which to search for and remove calendar events.
  • UseCustomRouting: Directs the cmdlet to use a custom routing path for sending meeting cancellations.

3 Use Cases for Remove-CalendarEvents in PowerShell

Let’s take a look at 3 practical use cases for the Remove-CalendarEvents cmdlet:

  1. Employee Departure: When an employee leaves the company, their calendar often contains recurring meetings and appointments that no longer need to exist. Using Remove-CalendarEvents, an admin can quickly clean up these events from the calendars of other attendees, preventing any confusion or clutter from meetings that the former employee had organized.
  2. Mergers or Department Restructuring: During a company merger or department restructuring, you may need to cancel or reschedule many meetings due to changes in teams, projects, or roles. The cmdlet allows an admin to bulk remove outdated or redundant calendar events that no longer align with the new organizational structure, which is pretty useful for different organizations.
  3. Cleaning Up After Mass Scheduling Errors: If a scheduling error leads to a large number of incorrect or unintended meetings, Remove-CalendarEvents can be used to quickly remove them. This saves time and prevents confusion that would result from hundreds or thousands of users receiving incorrect meeting invites or having their calendars flooded with unintended events.

Prerequisites to Run the Remove-CalendarEvents Command

To correctly use this cmdlet, make sure to take a look at these 3 prerequisites:

  • Permissions: You need the necessary permissions assigned to run this cmdlet. Not all parameters may be accessible unless they are part of the permissions granted to you. To verify the required permissions, refer to the "Find the permissions required to run any Exchange cmdlet" documentation on the official Microsoft website.
  • Mailbox Enabled for Sending Mail: The mailbox specified must still be enabled to send mail, as meeting cancellations need to be sent out to attendees or resources.
  • Meeting Organizer: The cmdlet only cancels meetings where the specified mailbox is the meeting organizer and the meeting has one or more attendees or resources. It does not cancel appointments or meetings without attendees or resources.

How to Use Remove-CalendarEvents in 3 Steps

Now, let’s cut to the chase and learn how to use the Remove-CalendarEvents command in three easy-to-follow steps.

Step 1: Identify the Mailbox and Date Range

Before running the command, connect to the correct Exchange environment. For on-premises, use Exchange Management Shell; for cloud setups, use Exchange Online PowerShell. Launch PowerShell as an admin and type:

Connect-ExchangeOnline -UserPrincipalName [email protected]


You'll be prompted to enter your credentials.

Then determine the mailbox that you want to clean up and specify the date range for the events you wish to remove. Once you have this information, you can proceed with the following step.

Step 2: Run the Cmdlet with the Appropriate Parameters

Next, execute the Remove-CalendarEvents cmdlet using the mailbox, start date, and end date defined in the previous step. This command targets all meetings organized by the specified user within the given date range and cancels them.

You can also use additional parameters like CancelOrganizedMeetings to ensure only meetings with attendees are affected.

Take a look at this example:

Remove-CalendarEvents -Identity [email protected] -CancelOrganizedMeetings -QueryWindowInDays 190



This command cancels all meetings organized by the user "[email protected]" within the next 190 days. Here’s another example:

Remove-CalendarEvents -Identity "Simon Smith" -CancelOrganizedMeetings -QueryStartDate 2-1-2024 -QueryWindowInDays 30 -PreviewOnly -Verbose

This command simulates the cancellation of all meetings organized by "Simon Smith" between February 1, 2024, and 30 days after that, without actually canceling them, and provides detailed output of what would happen using the Remove-CalendarEvents cmdlet with -PreviewOnly and -Verbose options.

Step 3: Verify the Cancellation and Communicate

After running the cmdlet, verify that the meetings have been successfully canceled. You can check the user’s calendar or communicate with the attendees to ensure that the cancellations have been processed correctly.

In this case, running the Get-CalendarDiagnosticObjects command is a great way to do it.

Ensure no cancellations have failed by reviewing any error messages or logs and that’s it.

Wrapping Up: Using Remove-CalendarEvents in PowerShell

The Remove-CalendarEvents cmdlet is a crucial tool for keeping your organization’s calendars tidy and manageable. Here’s a quick summary of the key points discussed here:

  • The command helps remove outdated or irrelevant meetings from a user’s calendar, particularly in situations like employee departures or organizational changes.
  • Remove-CalendarEvents streamlines the cleanup process, saving time and reducing the potential for scheduling conflicts.
  • This cmdlet is ideal for scenarios like employee exits, company mergers, or correcting mass scheduling errors.