How to determine the number of mailboxes in your exchange environment?

Posted on 2009-04-20
Last Modified: 2012-05-06
How to determine the number of mailboxes in your exchange environment?
Question by:rcpsmith
    LVL 6

    Accepted Solution

    If it's a one time thing, you can go to System Manager / Administrative Groups / first administrative groups / Servers / <servername> / First Storage Group / Mailbox Store / Mailboxe. Click on the right pane and press Control-A. The number of mailboxes will show up in the lower left corner as 'x selected objects'.
    LVL 2

    Assisted Solution

    Exchange 2003 I see. Put this in a vbs file and run it.

    From :-

    Remember to change the ServerList = Array("server1", "server2", "server3") line to suit your environment.
    Option Explicit
    On Error Resume Next
    Dim ServerList        ' List of computers to check
    Dim server            ' Current computer to check
    Dim fso                ' File System Object
    Dim strWinMgmts            ' Connection string for WMI
    Dim objWMIExchange        ' Exchange Namespace WMI object
    Dim listExchange_Mailboxs    ' ExchangeLogons collection
    Dim objExchange_Mailbox        ' A single ExchangeLogon WMI object
    Dim logfile            ' Output file
    Const cWMINameSpace = "root/MicrosoftExchangeV2"
    Const cWMIInstance = "Exchange_Mailbox"
    Const LOG_FILE = "EMailSize.csv"
    ' Set up the array of email servers
    ServerList = Array("server1", "server2", "server3")
    ' Set up log file
    set fso = CreateObject("Scripting.FileSystemObject")
    Set logfile = fso.CreateTextFile(LOG_FILE)
    logfile.WriteLine("""Display Name"",""Mailbox Size"",""Mailbox TotalItems"",""Mailbox StoreName"",""Mailbox ServerName""")
    ' Create the object string, indicating WMI (winmgmts), using the
    ' current user credentials (impersonationLevel=impersonate),
    ' on the computer specified in the constant cComputerName, and
    ' using the CIM namespace for the Exchange provider.
    WScript.Echo "Starting now"
    'The rest of the script will fetch mailbox sizes for our servers. Mailbox sizes are in Kilobytes. 
    For Each server in ServerList
        WScript.Echo "Starting " & server & " search."
        strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//" & server & "/" & cWMINameSpace
        'WScript.Echo strWinMgmts
        Set objWMIExchange = GetObject(strWinMgmts)
        ' Verify we were able to correctly set the object.
        If Err.Number <> 0 Then
            WScript.Echo "ERROR: Unable to connect to the WMI namespace."
            'The Resources that currently exist appear as a list of
            'Exchange_Mailbox instances in the Exchange namespace.
            Set listExchange_Mailboxs = objWMIExchange.InstancesOf(cWMIInstance)
            ' Were any Exchange_Mailbox Instances returned?
            If (listExchange_Mailboxs.count > 0) Then
                ' If yes, do the following:
                ' Iterate through the list of Exchange_Mailbox objects.
                For Each objExchange_Mailbox in listExchange_Mailboxs
                    ' Display the value of the Size property.
                    logfile.WriteLine("""" & objExchange_Mailbox.MailboxDisplayName & """,""" & objExchange_Mailbox.Size & """,""" & objExchange_Mailbox.TotalItems & """,""" & objExchange_Mailbox.StoreName & """,""" & objExchange_Mailbox.ServerName & """")
                ' If no Exchange_Mailbox instances were returned, display that.
                WScript.Echo "WARNING: No Exchange_Mailbox instances were returned."
            End If
        End If
    Wscript.Echo "Completed"

    Open in new window

    LVL 6

    Expert Comment

    This script will do the same thin automatically when run from the Exchange server:
    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\ROOT\MicrosoftExchangeV2")
    Set colItems = objWMIService.ExecQuery("Select * from Exchange_Mailbox")
    Wscript.Echo "TOTAL MAILBOX COUNT: " & colItems.count
    Set objWMIService = Nothing
    Set colItems = Nothing

    Open in new window

    LVL 5

    Assisted Solution

    You can also use the Exchange Best Practice analyzer. At the end, it reports that information as well as a lot of other useful information.

    It will also point out any things you need to fix in Exchange, which is its primary purpose. Mailbox count is just a nice side benefit.

    Featured Post

    How does your email signature look on mobiles?

    Do your employees use mobile devices to reply to emails? With mobile becoming increasingly important to the business world, it is in your best interest to make sure that your email signature looks great across all types of devices.

    Join & Write a Comment

    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
    To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now