Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery subject:
"Help-desk","Sent:28/01/2015", from:'someone@domain.com'
-TargetMailbox administrator -LogOnly -TargetFolder CustomSearch
This will generate a lot of output, and searching through all those lines in the Powershell console can be a pain. So i make things easy for myself and send it to myself.$Output = Get-Mailbox -ResultSize unlimited | Search-Mailbox
-SearchQuery subject:"Help-desk",from:'someone@domain.com'
-TargetMailbox administrator -LogOnly -TargetFolder CustomSearch
And then;Send-MailMessage -SmtpServer smtp.domain.com -To
edwin@domain.com -subject "List" -From edwin@domain.com
-Body ($output | out-string)
The email is much easier to search trhough.When you checked that the search went according to plan, you can finally delete all the emails you searched for by adding: -DeleteContent and removing -LogOnly
Get-Mailbox -ResultSize unlimited | Search-Mailbox
-SearchQuery subject:"Help-desk",from:'someone@domain.com'
-TargetMailbox administrator -TargetFolder CustomSearch -DeleteContent
Tip:You can also search for an entire domain by specifying: from:'@domain.com'.
Note that there is no * (wildcard) in front of the @ sign.
If you want to delete a message with the subject: Re:Help-desk you should use single quote's " ' " (marked in red). Using single quotes wille delete any subject that contains Help-desk, so Re:Help-desk would be deleted as well.
Example: 'Re:Help-desk'
If you want to delete only the subject: Help-desk you should use the double quote's " " "
Example: "Re:Help-desk"
Full description of the Search-Mailbox command let can be found here
Tony Redmond just posted a more in depth view on this subject, go check it out here.
I know this is old but I wish I could get it to work with exchange 2010. over 80 messages in the inbox with a specific subject and they can't be found. every attempt turns up either zero or 4. not sure how it can find 4 but not the other 80+ messages. just shoot me.
ReplyDelete