Help with Exchange Powershell
We're running Exchange 2010 SP1. Per our legal department's mandated email retention policy, I have to purge every mailbox at the quarters end of anything older than the end of the previous quarter. Before I do a purge, I also run a mailbox export against the same date range and save it off to a PST which the users have no/little access to, these are archived for 1 year.
In Exchange 2003 this was very easy to do by using ExMerge. Now that our Exchange 2010 migration is complete, I'm stuck using powershell to complete this task. I split it up into 2 scripts, one for the archive and one for the purge. Here are the 2 scripts:
Archive:
$mailboxes = get-mailbox -Database DB1
foreach ($mailbox in $mailboxes) {
new-mailboxexportrequest -ContentFilter {(Received -ge '01/01/2000') -and (Received -le '03/30/2013')} -mailbox $mailbox -FilePath "\\storage\Email Retention\2013Q2\$mailbox.pst"
}
Purge:
get-mailbox -database DB1 -resultsize unlimited | Search-Mailbox -SearchQuery "Received:> $('01/01/2000') AND Received:< $('03/30/2013') kind:email not kind:contacts not kind:tasks not kind:meetings AND sent:> $('01/01/2000') AND sent:< $('03/30/2013')" -DeleteContent
Does anyone know of a better way to do this? It takes forever to complete, I felt that it went much smoother with ExMerge. Unfortunately setting up a retention policy will not work because we need to be very specific with the date ranges.
Also with the purge script that I have posted above, can anyone tell me what all the object names are for using the kind: and not kind: options. If users have created a local Contact Group, using the contacts option does not include these, I found that out the hard way. I have had a heck of a time finding any documentation on this.
Posted Aug 1, 2013, 5:31 PM UTC
Prior to E2010 SP1 you could have done this all in one line, with the -deletecontent on the new-mailboxexportrequest but that has been depreciated.
As much as I want to question the decisions, I'm not. But I want to suggest journaling, it may be an option for you as there is no telling how many messages are deleted during the quarter that your users are deleting that you are not capturing. http://technet.microsoft.com/en-us/library/aa998649(v=exchg.141).aspx