Link to home
Start Free TrialLog in
Avatar of yo_bee
yo_beeFlag for United States of America

asked on

Exchange 2010 Powershell Search-mailbox Syntax

I want to search and destroy e-mails with a subject and Sent date

My syntax

Get-Mailbox -identity <name> | Search-Mailbox -SearchQuery {'Subject:"*Daily Revenue*" and Sent:"8/23/2015"'} -DeleteContent -Force

Open in new window


is this correct?
Avatar of K B
K B
Flag of United States of America image

Get-Mailbox -Server  "*Server*" | Search-Mailbox -SearchQuery 'Subject:"*Subject*" and Body:"*Body*"' -deletecontent

Or backup (sort of) the emails first ...

Copy all emails to a single mailbox, then delete the emails

Get-Mailbox -Server  "*Server*" | Search-Mailbox -SearchQuery 'Subject:"*Subject*" and Body:"*Body*"' -targetmailbox "*SearchMailbox*" -targetfolder "*SearchFolder*" -loglevel full -deletecontent
Avatar of yo_bee

ASKER

Thanks for the link, but I am asking is my syntax correct.
From what I can see in the example in the link I am putting  both the subject and sent date correctly. When I run it I get a long list of errors (which I cannot post at this moment).
ASKER CERTIFIED SOLUTION
Avatar of K B
K B
Flag of United States of America 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
Avatar of yo_bee

ASKER

I have not stumbled across this one yet. When I get home I will try it.
Avatar of yo_bee

ASKER

This helped me find the right path, but it turned out that the Syntax for the Date part can not me in quotes and I had to run it from the CAS  because of roll I have for my account.

Now there is another obstacle that I need to address ADRMS protected E-mails.

Get-Mailbox -Identity  UserName | Search-Mailbox -SearchQuery  {Subject:"*Daily Revenue*" AND received:8/23/2015} -DeleteContent -Force

Open in new window

Thanks for your help