Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to use powershell to gather emails that pertain to a certain subject, so that these correspondences might be turned over to a legal department. I am having a couple of issues here that I would like some assistance getting past.

I run the following command:

get-mailbox -Database "Mailbox Database" | 
Export-Mailbox -ContentKeywords "Keywords To Search" 
-TargetMailbox "sec_goat" 
-TargetFolder EmailSearch 
-StartDate "01/13/2011 12:01:00

This has pretty much done what I want, and returned a boat load of emails, however it has also flooded my inbox with hundreds of blank calendars and contact lists. I realize now I should have used the exclusion on these folders, as well as a test environment (which we don't have).

1.How can I clean up this script to not include all the blank folders, contacts and calendars that DO NOT match the keywords search?

2.How do I clean up hundreds of blank contact lists and calendars in my mailbox without right clicking and deleting each one?

EDIT: I edited the post to change the scope of the question. I think my focus is less on the legal perspective and more on the "How can I clean up my mess and make future archives less messy and painful?"

share|improve this question
I am not a legal expert but from experiance i would say that a powershell script would need to be carefully checked by someone in the know ( a lawer) that they are happy that system would stand up if needed. – t1nt1n Nov 6 '12 at 14:38
2. - ask your legal department what they want/need. And good luck with that. – HopelessN00b Nov 6 '12 at 14:39
"What is best practice for legal archiving?" A lawyer skilled in these things who can recommend a proper solution for it. – ceejayoz Nov 6 '12 at 14:41
@HopelessN00b We do Not have a legal department, too small for that, I guess it was a bad choice of words, we have a lawyer! – sec_goat Nov 6 '12 at 14:46
Then ask your lawyer what he wants/needs. And regarding 1., it seems like it might be easier to just blow everything away and run the export again, only including actual emails this time. – HopelessN00b Nov 6 '12 at 14:49
up vote 2 down vote accepted

In Exchange 2007, you should be exporting to a dedicated mailbox to prevent the stuff you''re seeing with the calendar and contacts. In Exchange 2010, the mailbox should be crated as a discovery mailbox. This disables things like calendar processing and recalls.

Other than that, your basic syntax is correct.

Simply deleting the folder that you exported to should clear up the calendar entries in your mailbox.

share|improve this answer
Awesome, that DID take care of all the extra calendars and contacts. Would you mind expanding on what a discovery mailbox is and how i should use it, I feel like then I will be able to mark this as the answer. – sec_goat Nov 6 '12 at 18:39
What version of Exchange are you using? Include service pack and roll-up level. – longneck Nov 6 '12 at 18:53
Version 8.1 (Build 240.6) That's all the info I can seem to find on it. – sec_goat Nov 6 '12 at 19:05
I keep looking into this "Discovery mailbox" but it appears to only be available in exchange 2010 and not 2007? I will go ahead and mark your response as the answer. Thanks! – sec_goat Nov 7 '12 at 13:20
i cleaned up my answer to cover the bases better. – longneck Nov 7 '12 at 16:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.