How to delete all calendar appointments booked by terminated users?

Deleted
Not applicable

We have  a Hybrid set up with o365 and we ahve around 150+ Meeting rooms.

How to delete all calendar appointments booked by terminated users?

Before deleting, we need to email out all attendees to make sure they know the meeting is getting removed.

We know that we can do it by enabling mailbox for terminated users and then by giving Full access permission on their mailbox and then deleting the appointments using OWA/Outlook App.


But how to do this using O365 Powershell?

 

Regards,

Sounder

 

37 Replies

If the user account still exists, use the Remove-CalendarEvents cmdlet: https://technet.microsoft.com/en-us/library/mt784593(v=exchg.160).aspx

 

That works only for cloud mailboxes though. Otherwise, you will have to use some EWS-based script to find and properly cancel the appointments. Removing them via Search-Mailbox will not send cancelcation notices.

Thanks Vasil.

If the user account DOES NOT  exists ( i.e. If the  On premsise AD account is in disabled state and o365 mailbox is in softdeleted state) then How to find all inactive users  that have booked meetings and how to cancel the meetings and then send email notifications to the attendees.

 

Any scrip will be very usefull for me

 

Thanks

Sounder

 

If the user doesnt exist, you will only be able to delete them (not cancel). There's an example script here: https://social.msdn.microsoft.com/Forums/en-US/c94b2f4b-a3a0-4006-973d-b150fae078ca/using-ews-to-can...

 

Just change the method to Delete on the last line...

It has been 1 year since this last post and the article refers to exch 2010, niet O365. Any new tips or methods on how to achieve this?

The answer is still the same. You can only Cancel meetings if the organizer's account still exists. Otherwise, best you can do is delete them.

I just spent two days working with Microsoft on this, user has been deleted due to being disabled and placed in an OU that doesn't sync.  Here is the command line:

 

Get-Mailbox -ResultSize Unlimited | Search-Mailbox -SearchQuery 'Kind:Meetings AND Organizer:EmailAddressOfExEmployee' -DeleteContent –Force

 

 

@Kerry Loftus

Could I ask for a little more information, we are experiencing the same issue, I ran the command in question but receive the following error:

 

The target mailbox or .pst file path is required.
+ CategoryInfo : InvalidArgument: (:) [], ArgumentException
+ FullyQualifiedErrorId : [Server=MAIL,RequestId=33b58e41-c74b-4db2-b552-c2e9ffe7489f,TimeStamp=1/8/2019 9:02:
18 PM] [FailureCategory=Cmdlet-ArgumentException] 8DBCE48A
+ PSComputerName : MAIL

 

This is less complicated and worked perfectly:

 

Search-Mailbox -Identity simpleuser@abc.com -SearchQuery 'kind:meetings AND From:user@abc.com' -DeleteContent

I dont believe this does the same thing.   Your script searches only one mailbox.   The previous script searches all mailboxes, effectively removing meetings form others' calendars as well.   This is useful when the terminated user had booked conference rooms that dont get freed up because cancellation notices are not sent out.  

Open the MS Office 365 admin center - resources - Rooms & equipment - select the resource and scroll to bottom (look for Edit Exchange settings - go to mailbox delegation - Full Access -add yourself - log out of your outlook and back in for the change to take. 

Now you have permission to delete the calendar entries.

@Jeffrey Suarez thanks but an extremely long method for a large organisation. 

@Jeffrey Suarez 

 

I needed this and worked. Many Thanks.

@Kerry Loftus  HI, today i am using this command but its show this command is expire, can u please help me. 

also getting this error

Technical_Admin_0-1586934354557.png

 

@Technical_Admin what is it you're trying to achieve?

 

The end of life warning shouldn't be preventing your end goal, as that's just a warning for Microsoft support no longer existing.

 

Your SSL error is probably going to be down to a syntax error.

@Kerry Loftus Can you please explain what exactly this command do?

Might be a late answer, but we used the following command to clear out meetings booked by terminated users:

Remove-CalendarEvents -Identity user@domain.com -CancelOrganizedMeetings -QueryWindowInDays 180

 

@Jeffrey Suarez  Not exactly the answer,

If the user account does NOT exist How to find all inactive users who have booked meetings and how to cancel them and then send email notifications to attendees

@Kerry Loftus It looks like Search-Mailbox is deprecated.  What would be the new command for this?  

New-ComplianceSearchAction does not seem to have a delete function.

@StephenHoos

Creating a compliance search for any messages of kind:meetings from the terminated user and running the following command worked for me:

 

New-ComplianceSearchAction -SearchName "SEARCH TO DELETE" -Purge -PurgeType SoftDelete

 

Full instructions here: Search for and delete email messages in your Office 365 organization - Admin Help | Microsoft Docs