Recently I was working with a customer on a case with Exchange 2007 where they were trying to use Export-Mailbox to remove specific items from a user’s mailbox, as documented here:
In this case, we were attempting to remove all items matching certain subject keywords from the Inbox. So, the command we were running looked something like this:
Export-Mailbox -Identity username -IncludeFolders "\Inbox" -TargetMailbox mytargetmailbox -TargetFolder "Test" -SubjectKeywords "[Suspected spam] Alert" -DeleteContent
The command ran without any errors, and appeared to work on exporting messages, but when it was done, no messages appeared in the target mailbox, and the messages that should have been removed from the mailbox were not removed.
In further testing, we found that we could use Export-Mailbox to export the entire Inbox to the target, and we could also export from a couple of other users’ mailboxes using the subject keywords successfully.
At this point, I checked with one of the Escalation Engineers (the guys that actually look through code) here and they suggested that if the mailbox that worked was on a different store, the most likely cause was corruption of the content index for the store the problem mailbox is on.
So, given that it appeared the problem was corruption of the content index, our solution was to rebuild the index. We used the information found here (In #2 under “To Rebuild the Full-Text Index Catalog Using the ResetSearchIndex.ps1 Script”) to do so:
After rebuilding the index, the Export-Mailbox command worked perfectly using the SubjectKeywords. So, if you find that you’re having problems exporting from mailboxes using keywords, you might try resetting the index catalog.