Recipe 17.15. Enumerating Disconnected MailboxesProblemYou want to enumerate all disconnected mailboxes on a server. SolutionUsing a graphical user interface
Using VBScript' This code enumerates disconnected mailboxes. ' ------ SCRIPT CONFIGURATION ------ strComputer = "<Exchange Server>" 'e.g., ExchServer2 ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & _ "\root\MicrosoftExchangeV2") set objDiscMbx = objWMI.ExecQuery("Select * from Exchange_Mailbox",,48) for each objMbx in objDiscMbx if (objMbx.DateDiscoveredAbsentInDS <> "") then Wscript.Echo objMbx.MailBoxDisplayName & " " & _ objMbx.DateDiscoveredAbsentInDS end if next Wscript.Echo "Successfully enumerated disconnected mailboxes." DiscussionWhen you tell the system to delete an Exchange mailbox, it isn't really deleted. It is simply disassociated or disconnected from the user object. These mailboxes are referred to as orphaned or disconnected. This recipe shows you how to enumerate the disconnected mailboxes you have on a specified server.
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 VBScriptThis is one of the occasions where a script is faster and easier than the corresponding GUI. There is no method to just enumerate disconnected mailboxes in ESM. You actually have to go down the list and look at every mailbox. If you have thousands of mailboxes, this could be tedious. If you have thousands of mailboxes across many servers, it can quickly become unmanageable. The DateDiscoveredAbsentInDS property is part of the Exchange_Mailbox class, which is new for Exchange 2003.
See AlsoExchange Server 2003 SDK: WMI Reference |