A question came via email asking to help with deleting all calendar entries in an Exchange 2010 mailbox. Let’s find out how to do it.
The calendar in question had thousands of entries and hence the exchange admin wanted to clear it all using PowerShell. A one-liner will do the job, provided that you know how to filter the calendar entries alone in a mailbox
This question came in response to my article about how to delete all items in the recoverable items folder in an Exchange 2010 mailbox. We will use the same cmdlet along with an advanced query syntax to filter only the calendar entries.
The command to run is as follows.
Search-Mailbox –identity username –SearchQuery kind:meetings –DeleteContent
You can get an estimate about the number of entries and size that will be freed up after deletion by running
Search-Mailbox –identity username –SearchQuery kind:meetings –EstimateResultOnly
Similarly, you can delete contacts, notes, tasks, im & emails by changing the search query.
Search-Mailbox –identity username –SearchQuery kind:contacts –DeleteContent
Search-Mailbox –identity username –SearchQuery kind:notes –DeleteContent
Search-Mailbox –identity username –SearchQuery kind:tasks –DeleteContent
Search-Mailbox –identity username –SearchQuery kind:im –DeleteContent
Search-Mailbox –identity username –SearchQuery kind:email –DeleteContent
Always use the EstimateResultOnly parameter first, before deleting the content. Just in case your query is not right