I'm not really sure if this is possible with Powershell so thought I would ask here first for a quick brainstorm! Essentially I need to search through all mailboxes in a given Exchange looking for specific strings - multiple forms of these strings - lets say in this case - any email containing a set of 6 numbers in any of the following formats:
`xx-xx-xx
xxxxxx
xxx-xxx`
Where x is a number in this case. So if any of these strings are found in the mail, it logs to a text file the mailbox and email/subject it is contained in.
My logic would be as follows:
Search Exchange and loop for every mailbox
Recurse in every mailbox looking for matches for the above criteria
If it finds something - get info about that mail, write to text file
Continue loop
Any ideas!
Thanks
this is for Exchange 2010 from the Exchange Management Shell:
#Assign the role to the required user account
New-ManagementRoleAssignment -Role “Mailbox Import Export” -User administrator
#Restart the shell
#This would search every mailbox for messages containing the word xx-xx-xx in the message body,
#and export them to the administrator mailbox in a subfolder called Export
Get-Mailbox -ResultSize Unlimited | Search-Mailbox -SearchQuery “Body:’*xx-xx-xx*’” -TargetMailbox administrator -TargetFolder Export
You need to do this for any [string] you are searching.
I think there's cmdlet also in exchange 2007 to do same thing, but I can swear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With