Link to home
Start Free TrialLog in
Avatar of CiscoAzn
CiscoAznFlag for United States of America

asked on

powershell script to query and delete emails

Is there a Powershell script to query and delete emails by subject? If someone sends a bad email to a multiple large distribution group i like to search and remove based on subject.
Avatar of Akhater
Akhater
Flag of Lebanon image

if you are talking about exchange 2010 and newer here is what you want
https://technet.microsoft.com/en-us/library/ff459253(v=exchg.160).aspx

make sure to pick the exchange version corresponding to the one you have
Avatar of CiscoAzn

ASKER

This is for Exchange 2010. The link you sent me is for Exchange 2016.
:) this is for all exchange versions, just pick the one you want on top of the article

anyway here you go https://technet.microsoft.com/en-us/library/ff459253(v=exchg.141).aspx

User generated image
In the Exchange 2010 version it only shows the search for a mailbox not for the entire org and that's what i'm looking for.
It is the same thing

Get-Mailbox | search-mailbox -deletecontent

Will do it for all mailboxes
Thanks Akhater but how do you get a count of the total emails that it query and the total emails that it found before deleting it?
ASKER CERTIFIED SOLUTION
Avatar of Akhater
Akhater
Flag of Lebanon image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for the late response but thank you for your assistance.