Searching Exchange 2010 mailboxes with Powershell

#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 secrets in the message body,
#and export them to the administrator mailbox in a subfolder called Export
Get-Mailbox -ResultSize Unlimited | Search-Mailbox -SearchQuery “Body:’*secrets*'” -TargetMailbox administrator -TargetFolder Export
#Or, to search one mailbox for bob smith
Search-Mailbox -Identity bsmith -SearchQuery “Body:’*secrets*'” -TargetMailbox administrator -TargetFolder
#you can also do this via ECP