Link to home
Start Free TrialLog in
Avatar of adaniel93475
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 Jamie McKillop
Jamie McKillop
Flag of Canada image

Hello,

You want to run:

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

-JJ
Avatar of adaniel93475
adaniel93475

ASKER

JJ

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?
ASKER CERTIFIED SOLUTION
Avatar of Jamie McKillop
Jamie McKillop
Flag of Canada 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
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).