Delete all calendar appointments for a list of users using powershell

%3CLINGO-SUB%20id%3D%22lingo-sub-1518356%22%20slang%3D%22en-US%22%3EDelete%20all%20calendar%20appointments%20for%20a%20list%20of%20users%20using%20powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1518356%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBecause%20of%20scheduling%20remote%20learning%20classes%2C%20the%20teachers%20has%20got%20numerous%20calendar%20events%20in%20their%20Teams%20calendar%20and%20its%20crashing%20the%20Teams%20app.%20Can%20somebody%20please%20help%20me%20with%20a%20powershell%20script%20to%20clear%20the%20calendar%20events%20for%20a%20list%20of%20users%20using%20input%20file%20(csv%20or%20txt).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-ERR%3AREF-NOT-FOUND-%40Tony%20Redmond%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3EMuhamed%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1518356%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ECalendar%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EO365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%20Commands%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETeams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1518428%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20all%20calendar%20appointments%20for%20a%20list%20of%20users%20using%20powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1518428%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F587908%22%20target%3D%22_blank%22%3E%40muhamedrafeeq%3C%2FA%3E%26nbsp%3B%20This%20shouldn't%20happen.%20File%20a%20support%20incident%20with%20Microsoft%20to%20have%20them%20investigate%20why%20the%20calendar%20is%20causing%20a%20problem.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1523295%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20all%20calendar%20appointments%20for%20a%20list%20of%20users%20using%20powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1523295%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20guys%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20really%20need%20to%20remove%20the%20calendar%20events%20for%20many%20staffs%20(o365%20mailbox).%20Can%20somebody%20share%20a%20powershell%20script%20to%20do%20the%20same%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ERafeeq%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1524135%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20all%20calendar%20appointments%20for%20a%20list%20of%20users%20using%20powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1524135%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F587908%22%20target%3D%22_blank%22%3E%40muhamedrafeeq%3C%2FA%3E%26nbsp%3Bhave%20you%20tried%20using%20the%26nbsp%3BRemove-CalendarEvents%20script%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1530916%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20all%20calendar%20appointments%20for%20a%20list%20of%20users%20using%20powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1530916%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F674460%22%20target%3D%22_blank%22%3E%40Ardamilola%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%20I%20tried%20the%20%3CSPAN%3ERemove-CalendarEvents%26nbsp%3B%3C%2FSPAN%3Escript%2C%20but%20I%20believe%20that%20script%20is%20for%20future%20meetings%20and%20I%20want%20to%20clear%20the%20past%20meeting%20entries%20too.%20Also%20I%20got%20to%20clear%20calendar%20events%20for%20around%201000%2B%20users.%20So%20a%20script%20which%20calls%20the%20input%20list%20would%20be%20feasible.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1988050%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20all%20calendar%20appointments%20for%20a%20list%20of%20users%20using%20powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1988050%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F587908%22%20target%3D%22_blank%22%3E%40muhamedrafeeq%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F674460%22%20target%3D%22_blank%22%3E%40Ardamilola%3C%2FA%3E%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDid%20you%20solve%20this%20problem%3F%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20facing%20the%20exactly%20problem%20here.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3ERemove-CalendarEvents%20-Identity%20user%40domain.com.br%20-CancelOrganizedMeetings%20-Confirm%3A%24false%20-verbose%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CEM%3EGet-Mailbox%20-ResultSize%20Unlimited%20%7C%20Search-Mailbox%20-SearchQuery%20%22kind%3Ameetings%20AND%20From%3Auser%40domain.com.br%22%20-DeleteContent%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20no%20success%20%3A(%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1988519%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20all%20calendar%20appointments%20for%20a%20list%20of%20users%20using%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1988519%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F901961%22%20target%3D%22_blank%22%3E%40victor_fernande%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20problem%20with%20Remove-CalendarEvents%20is%20that%20it's%20forward%20looking%20and%20I%20suspect%20that%20you%20want%20to%20remove%20events%20in%20the%20past.%20This%20can%20be%20done%20with%20the%20Search-Mailbox%20cmdlet%20using%20a%20command%20something%20like%20this%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3ESearch-Mailbox%20-Identity%20MailboxtoSearch%20-SearchQuery%20'Received%3A01-Jan-2019..15-Dec-2020%20kind%3Ameetings'%20-TargetFolder%20Searches%20-TargetMailbox%20AnotherMailbox%20-LogOnly%20-LogLevel%20Full%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20command%20looks%20for%20calendar%20meeting%20events%20in%20a%20certain%20date%20range%20and%20creates%20a%20report%20in%20the%20target%20folder%20in%20the%20target%20mailbox.%20If%20you%20want%20to%20delete%20the%20items%2C%20run%3A%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3ESearch-Mailbox%20-Identity%20MailboxtoSearch%20-SearchQuery%20'Received%3A01-Jan-2019..15-Dec-2020%20kind%3Ameetings'%20-DeleteContent%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1990139%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20all%20calendar%20appointments%20for%20a%20list%20of%20users%20using%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1990139%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F64%22%20target%3D%22_blank%22%3E%40Tony%20Redmond%3C%2FA%3E%26nbsp%3B%20!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20issued%20this%20command%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CEM%3Esearch-Mailbox%20-Identity%20user%40domain.com.br%20-SearchQuery%20%22kind%3Ameetings%22%20-DeleteContent%20-confirm%3A%24false%20-Force%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20Worked%20!%20thank%20you%20for%20your%20time%20!%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ealso%20I%20used%20%3CEM%3E%3CSTRONG%3E-confirm%3A%24false%20-Force%26nbsp%3B%3C%2FSTRONG%3E%3C%2FEM%3Ebecause%20i%20needed%20to%20run%20in%20many%20users.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20Again%20!%20Best%20Regards%20!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1995974%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20all%20calendar%20appointments%20for%20a%20list%20of%20users%20using%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1995974%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F901961%22%20target%3D%22_blank%22%3E%40victor_fernande%3C%2FA%3E%26nbsp%3B%20FYI%2C%20you%20might%20like%20the%20script%20described%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Foffice365itpros.com%2F2020%2F12%2F17%2Fuse-powershell-remove-exchange-online-mailbox-items%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHow%20to%20Use%20PowerShell%20to%20Remove%20Calendar%20Items%20from%20Exchange%20Online%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi,

 

Because of scheduling remote learning classes, the teachers has got numerous calendar events in their Teams calendar and its crashing the Teams app. Can somebody please help me with a powershell script to clear the calendar events for a list of users using input file (csv or txt).

 

@Tony Redmond 

 

Regards,

Muhamed

8 Replies

@muhamedrafeeq  This shouldn't happen. File a support incident with Microsoft to have them investigate why the calendar is causing a problem.

Hi guys,

 

I really need to remove the calendar events for many staffs (o365 mailbox). Can somebody share a powershell script to do the same ?

 

Regards,

Rafeeq

@muhamedrafeeq have you tried using the Remove-CalendarEvents script ?

Hi @Ardamilola ,

 

Yes I tried the Remove-CalendarEvents script, but I believe that script is for future meetings and I want to clear the past meeting entries too. Also I got to clear calendar events for around 1000+ users. So a script which calls the input list would be feasible.

Hi @muhamedrafeeq and @Ardamilola

 

Did you solve this problem? 

I'm facing the exactly problem here. 

 

I tried 

Remove-CalendarEvents -Identity user@domain.com.br -CancelOrganizedMeetings -Confirm:$false -verbose

 

and


Get-Mailbox -ResultSize Unlimited | Search-Mailbox -SearchQuery "kind:meetings AND From:user@domain.com.br" -DeleteContent

 

But no success :(

@victor_fernande 

 

The problem with Remove-CalendarEvents is that it's forward looking and I suspect that you want to remove events in the past. This can be done with the Search-Mailbox cmdlet using a command something like this:

 

Search-Mailbox -Identity MailboxtoSearch -SearchQuery 'Received:01-Jan-2019..15-Dec-2020 kind:meetings' -TargetFolder Searches -TargetMailbox AnotherMailbox -LogOnly -LogLevel Full

 

This command looks for calendar meeting events in a certain date range and creates a report in the target folder in the target mailbox. If you want to delete the items, run: 

 

Search-Mailbox -Identity MailboxtoSearch -SearchQuery 'Received:01-Jan-2019..15-Dec-2020 kind:meetings' -DeleteContent

 

Thank you @Tony Redmond  !

 

I issued this command

 

search-Mailbox -Identity user@domain.com.br -SearchQuery "kind:meetings" -DeleteContent -confirm:$false -Force

 

and Worked ! thank you for your time ! 

 

also I used -confirm:$false -Force because i needed to run in many users. 

 

Thanks Again ! Best Regards !