Sunday, July 23, 2017

Exchange Cleaning Up Meetings From Terminated Employee

You have a user who has left the company and they have a bunch of meetings scheduled on Room Mailboxes; this is probably something every exchange admin has to deal with at least once.
If you have a small organization or a limited number of rooms, those meetings can be taking up valuable timeslots that other users could be using.
Why there's not an automated mechanism to remove those meetings when you disable a mailbox? I dunno :(

A lot of times, you might have also granted Full Access to that user's mailbox for someone that has taken over their responsibilities, and that person gets annoying alerts for meetings that no longer need to be scheduled.

I'll show you how to delete the meetings from the Room Mailboxes in one shot, and how to remove all meetings from the user's mailbox calendar by using PowerShell.

Deleting Meetings From the User's Calendar:

First, we'll get a count of how many meetings the user has. This will be useful to ensure that the cleanup cmdlet works later.

Fire up the Exchange Management Shell (EMS) and run the following:

Search-Mailbox -identity disableduseraccountname -SearchQuery kind:meetings -EstimateResultOnly | Out-File C:\Temp\DeletedUserMeetings.txt

**Note** Change disableduseraccountname to name of the user's mailbox, and change the TXT file path.

The above cmdlet will spit out a TXT file with all the meetings that the departed user had scheduled.

The reason I pipe it out to a TXT file, is because there might be tons of meetings...I've seen a user with 6000 meetings scheduled. They thought they'd be with the company until the year 2045 :)

Next, we'll delete all those meetings, by running:

Search-Mailbox -identity disableduseraccountname -SearchQuery kind:meetings -DeleteContent

Once that cmdlet completes, you can run the first one with the -EstimateResultOnly switch to verify all meetings are gone.

Deleting Meetings From the Room Mailboxes:

Now, we'll clean up all meetings scheduled by the terminated user from every room mailbox, in bulk.

Again, we're gonna check and see how many meetings exist for this user, by running:

Get-Mailbox -RecipientTypeDetails roommailbox | Search-Mailbox -searchquery "kind:meetings from:disableduseraccountname" -EstimateResultOnly | Out-File C:\Temp\DeletedUserRoomMailboxMeetings.txt

**Note** Change disableduseraccountname to the mailbox name and the file path.

The cmdlet will search all Room Mailboxes for any meeting scheduled by the terminated user and output a TXT file.

Now, we'll delete all those meetings from the Room Mailboxes:

Get-Mailbox -RecipientTypeDetails roommailbox | Search-Mailbox -searchquery "kind:meetings from:disableduseraccountname" -deletecontent

This cmdlet will search those Room Mailboxes, deleting any meeting scheduled by the supplied user.

You can run the estimate results cmdlet again to verify they were deleted, or open up one of the Room Mailboxes in Outlook and see if any meeting still exists on the calendar.

No comments:

Post a Comment