Recipe17.15.Enumerating Disconnected Mailboxes


Recipe 17.15. Enumerating Disconnected Mailboxes

Problem

You want to enumerate all disconnected mailboxes on a server.

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 view disconnected mailboxes.

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

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

Discussion

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 in order to do this with a script, the WMI provider also requires local administrator permissions on the Exchange server. 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

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

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

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