Avatar of adaniel93475
 asked on

Delete emails from mailbox - Exchange 2010 SP2

Anyone know what the right syntax in Powershell is to delete emails based on date or even subject?
i have tried:
get-mailbox -id "arun daniel" | Search-Mailbox -SearchQuery subject:"Your bank statement" -DeleteContent

I end up getting: The target mailbox or .pst file path is required

Avatar of undefined
Last Comment

8/22/2022 - Mon
Jamie McKillop


You want to run:

Search-Mailbox -Identity "arun daniel" -SearchQuery subject:"Your bank statement" -DeleteContent



Yeah, i tried that as well but i get this:
[PS] C:\Windows\system32>Search-Mailbox -Identity "arun daniel" -SearchQuery subject:"Your bank statement" -DeleteContent
A positional parameter cannot be found that accepts argument '-DeleteContent'.
    + CategoryInfo          : InvalidArgument: (:) [Search-Mailbox], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Search-Mailbox

[PS] C:\Windows\system32>

From my readings, it looks like -DeleteContent is no longer available for SP2?
Jamie McKillop

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks JJ! other than my fat fingers, i just found out that i have to run that on the source mailbox server (as opposed to the CAS server i always do my work on).
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes