I'm facing a challenge with deleting around 2000 email items from 8 different mailboxes. I explored using eDiscovery to pull all the data, but I haven't been able to find a way to delete the items. Also, when I connect to Exchange Online, I'm limited to deleting only 10 items per search. What are some options available to effectively purge these emails?
4 Answers
The compliance search method is super effective. Make sure to create a tight search query to avoid deleting the wrong emails. Use `New-ComplianceSearchAction -Purge -PurgeType HardDelete` to finish the job. This method should allow you to process far more than just 10 items at a time.
If most of the emails are from the same source, consider doing a message trace first. You can open them in Explorer and hard delete the ones you don't need. Just be careful to confirm what you're deleting beforehand.
You should definitely look into the Graph API, as it usually offers a more flexible approach. Using filters can help improve performance when deleting messages. Get familiar with commands like `Get-MgUserMessage`, check the results, and then pass those to the delete command. However, practice with a few items before you delete in bulk to avoid mistakes!
You might want to check out how to use PowerShell for this task. There's a great Microsoft guide on this. Using commands like `New-ComplianceSearch` along with `New-ComplianceSearchAction -Purge` can help. Make sure your compliance search query is specific so you don’t accidentally delete important emails. And remember, the 10-item limit applies only to the deprecated Search-Mailbox cmdlet, so using compliance search will help you overcome that.
Got it! Just to clarify, can I still encounter limits with compliance search if I have too many matching items?

Thanks for this tip! I tried the purge command, but it says the parameter cannot be found. Any idea how to troubleshoot that?