Friday, August 15, 2014

Searching Exchange 2010 mailboxes from Powershell

Customer Service reported an email they never received.. and the sender says they did not get an NDR.  I found a VERY nice explanation Here.

We have a Barracuda Spam Filter 300 in place, however it's dreadfully slow lately.  So searching it's logs takes FOREVER.

So I went to the Exchange side of things..

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery attachment:<filename> -TargetMailbox <name of mailbox> -TargetFolder <name of folder> -LogOnly -LogLevel Full

So I specified subject:'Woodbury Hospital' and a -targetmailbox as my own.  I had questioned whether or not the targetfolder needed to exist or not.  I created a folder, specified it as the target but the cmdlet created it's own subfolder with the specified name.

You can also delete emails using this method as well, as seen here:

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery subject:<verbatim subject line> -DeleteContent

Now if you wanted to search all mailboxes, copy the results then delete the content you;d do this:

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery subject:<verbatim subject line> -TargetMailbox <name of mailbox> -TargetFolder <name of folder> -DeleteContent












No comments:

Post a Comment