yo_bee
asked on
Exchange 2010 Powershell Search-mailbox Syntax
I want to search and destroy e-mails with a subject and Sent date
My syntax
is this correct?
My syntax
Get-Mailbox -identity <name> | Search-Mailbox -SearchQuery {'Subject:"*Daily Revenue*" and Sent:"8/23/2015"'} -DeleteContent -Force
is this correct?
http://ivan.dretvic.com/2011/05/remove-specific-email-from-all-mailboxes-in-exchange-2010-sp1/
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
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
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).
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have not stumbled across this one yet. When I get home I will try it.
http://community.spiceworks.com/topic/302333-powershell-exchange-delete-a-users-emails-older-than-x-days-and-x-size?page=1#entry-1980175
-SearchQuery '(Received:09/20/2012..10/ 12/2012)' -deletecontent
-SearchQuery '(Received:09/20/2012..10/
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.
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
Thanks for your help