Recipe17.13.Purging a Deleted Mailbox


Recipe 17.13. Purging a Deleted Mailbox

Problem

You want to purge a deleted mailbox from the Exchange Store.

Solution

Using a graphical user interface

  1. Open the Exchange System Manager (ESM) snap-in.

  2. In the left pane, browse to the mailboxes container of the server, storage group, and database where you want to purge a mailbox.

  3. In the left pane, scroll down until you find the mailbox that you wish to purge. The mailbox should have a small red circle with a white X in it, indicating it is disconnected.

  4. Right-click the mailbox and select Purge.

  5. When prompted if you are sure you want to continue, click Yes.

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

Discussion

A 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.

Purging a mailbox requires Exchange Service Administrator permissions. See the Discussion for Recipe 17.7.


Using a graphical user interface

You 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 VBScript

The 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.

Because this script uses Exchange WMI extensions, it can be run from any machine that has WMI; the machine does not need the Exchange Management Tools loaded.


See Also

Exchange Server 2003 SDK: WMI Reference



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net