Enumerating Disconnected Mailboxes

Enumerating Disconnected Mailboxes


You want to enumerate all disconnected mailboxes on a server.


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 for which you want to view disconnected mailboxes.

  3. In the right pane, scroll down through the list, taking note of all mailboxes with a small red circle with an X.

Using VBScript
	' This code enumerates disconnected mailboxes.
	strComputer = "<Exchange Server>" 'e.g. ExchServer2
	' ------ END CONFIGURATION ---------
	set objWMI = GetObject("winmgmts:\\" & strComputer & _

	set objDiscMbx = objWMI.ExecQuery("Select * from Exchange_Mailbox",,48)
	for each objMbx in objDiscMbx
	  if (objMbx. 
DateDiscoveredAbsentInDS <> "") then
	     Wscript.Echo objMbx.MailBoxDisplayName & " " & _
	  end if
	Wscript.Echo "Successfully enumerated disconnected mailboxes."


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

Viewing mailbox details in the ESM requires Exchange View Admin role access. However, to do this with a script, the WMI provider also requires local administrator permissions on the Exchange server. See the "Discussion" in Recipe 22.7.

Using VBScript

This is one of the occasions where a script is not only quicker than the corresponding GUI, but also much easier. There is no method to just enumerate disconnected mailboxes in ESM. You have to actually go down the list and look at every mailbox. If you have thousands of mailboxes, this could be quite 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.

Since this script uses Exchange WMI extensions, it can be run from any machine that has WMI. The machine does not have to have the Exchange Management Tools loaded.

See Also

Recipe 22.7 and Exchange Server 2003 SDK: WMI Reference

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows