Recipe 17.13. Purging a Deleted MailboxProblemYou want to purge a deleted mailbox from the Exchange Store. SolutionUsing a graphical user interface
Using VBScript' This code purges a deleted mailbox. ' ------ SCRIPT CONFIGURATION ------ strComputer = "<Exchange Server>" 'e.g., ExchServer2 strMailbox = "<Mailbox Alias>" 'e.g., jsmith ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & _ "\root\MicrosoftExchangeV2") set objDiscMbx = objWMI.ExecQuery("Select * from Exchange_Mailbox WHERE " _ & "MailboxDisplayName='" & strMailbox & "'",,48) for each objMbx in objDiscMbx objMbx.Purge next Wscript.Echo "Successfully purged mailbox." DiscussionA mailbox that has been deleted still has physical presence in the Exchange store. This recipe wipes that mailbox completely from the store. Once a mailbox has been purged, the only way to retrieve it is through restoring from a backup, which could be a lengthy process given the need to recover the entire store. In other words, don't do this unless you are sure of the consequences.
Using a graphical user interfaceYou may run into a case where ESM doesn't show you a mailbox is disconnected when in fact you know it is. This can happen if you delete the mailbox and immediately look at it in ESM. In order to clear that condition, you will need to right-click on the mailboxes container and select Run Cleanup Agent, causing some house cleaning to be done. The mailbox should then show up as disconnected. Using VBScriptThe Purge method is part of the Exchange_Mailbox class, which is new for Exchange 2003. In Exchange 2000, there was no method available to purge a mailbox via a script. Be extremely careful with this script because it could easily remove all disconnected mailboxes on a given Exchange server. In the SELECT statement of the WMI query, if the WHERE clause is removed, the purge loop below that would then clear every mailbox that was disconnected, so be careful.
See AlsoExchange Server 2003 SDK: WMI Reference |