Archiving Exchange Mailboxes with Exmerge

This method has now been updated for Exchange 2007.

Yesterday I posted about archiving home directories by zipping them with an extensible MA, and today I’m going to write about doing something similar with Exchange mailboxes.

Exchange mailboxes are most usefully archived to PST files, and the only way I found to automate it was Exmerge.

To install Exmerge on your MIIS server first install the Exchange System Management Tools, then follow the MS Exmerge instructions. Make sure you don’t have Outlook installed on the server – they won’t work together.

The big point to note about using Exmerge is that it won’t work if the user account has been disabled or deleted. It is therefore critical that you get the mailboxes archived before allowing an export to AD that will close the account.

Now it should be perfectly possible to do all this with an Extensible MA, much the way I did with the home directories. You would call Exmerge as part of the export step in the CSExtension code, and only change the Status once the mailbox had been successfully archived. Flowing the Status back into the metaverse would be a trigger for disabling/deleting the user account in AD.

If I was setting up an environment where only the odd account was disabled here and there I would probably do it that way. However, in the university environment I was working in, several hundred accounts would be disabled at a time. Exmerge can be quite slow, especially on large mailboxes (we were generous to our students). It also has a neat multi-threading capability, allowing it to plough through several mailboxes at a time – but only if you give it the whole list at once. MIIS, by it’s very nature, works on a single object at a time – so I found it preferable to run Exmerge outside MIIS.

Rather that an Extensible MA, I just used a simple SQL MA to populate a list of pending Disables. My queuing system periodically checks the list for mailboxes to be archived – though there’s no reason why a Scheduled Task wouldn’t work just as well. If there are any there, they are placed in a text file and Exmerge fired up to deal with then. Another script checks the Exmerge logs for success or failure messages, and updates the Status accordingly. Once the mailbox staus of “archived” is flowed back into the metaverse the account can be safely disabled.

I’m not going to go into a lot more detail about this, other than to link to some vbscript snippets which may be of use.

  1. Check if Exmerge is already running
  2. Populate per-server lists for Exmerge
  3. Run Exmerge
  4. Check the Exmerge log for results