Purging a Deleted Mailbox

Posted: March 27, 2010 in Active Directory, Exchange Server, Server, System Information
Tags: ,


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 you want to purge a mailbox from.
  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 that 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 from the store completely. 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 Full Administrator permissions..

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. To clear that condition, you will need to right-click on the mailboxes container and select Run Cleanup Agent. This will cause 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. If the WHERE clause is removed in the SELECT statement of the WMI query, the purge loop below that would then clear every mailbox that was disconnected, so be careful.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s