How can I search for and delete emails by subject in Exchange 365?

0
11
Asked By TechNinja42 On

I'm trying to write a PowerShell script using MSGraphConnector to find specific emails by their subject line and then delete them from mailboxes. However, I'm running into an error when using Connect-MgGraph: it says it can't bind the 'ClientSecretCredential' parameter because it can't convert my secret key string into the required type. I've spent too long on this and figured there must be a better way to do it in Exchange. I don't have Defender for Office 365. Can anyone assist me?

5 Answers

Answered By CuriousCat99 On

You could also just throw your question into ChatGPT; it might spit out a quick solution for you!

Answered By ScriptGuru88 On

You should look into eDiscovery and check out the command **New-ComplianceSearchAction -Purge**. You can use this command even without Defender, but make sure you have the Compliance Administrator role in your M365 tenant.

EmailBuster99 -

Right, the Defender isn't necessary, but just to add, having the right permissions is key to making this work.

Answered By AdminWhiz123 On

You can actually use Purview Content Search for this. It’s a solid way to search and manage emails without needing to dig too deep into PowerShell.

Answered By CodeCrafters On

If you're scripting, using the dedicated PowerShell cmdlets for Purview content searches is likely the simplest approach. Otherwise, just hop on the Purview website for guidance on how to search mailbox data.

Answered By PolicyPioneer On

Honestly, I’d skip PowerShell altogether for this. Just go with eDiscovery; it’s much easier to handle.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.