Powershell Script to help archive company email

Posted by sec_goat on Server Fault See other posts from Server Fault or by sec_goat
Published on 2012-11-06T14:36:23Z Indexed on 2012/11/07 17:03 UTC
Read the original article Hit count: 173

Filed under:
|

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?"

© Server Fault or respective owner

Related posts about exchange

Related posts about powershell