Need Mailbox Sizes and Target addresses from 2003 mailboxes RRS feed

  • Question

  • I'm am about to decom our old 2003 exchange server, but I need to gather some information prior to decom. I need to get the mailbox sizes of all users and the "TargetAddress" for each user (Blank or populated)

    I have a script to gather all of the mailbox sizes, but am trying to incorporate the target address as a column into the results.

    On Error Resume Next
    Const wbemFlagReturnImmediately = &h10
    Const wbemFlagForwardOnly = &h20
    CONST FileName ="D:\scripts\Exch2003Stats.csv"
    arrComputers = Array("Server1","Server2")
    q = """"
    Set objFSO = CREATEOBJECT("Scripting.FileSystemObject")
    Set objCSV = objFSO.createtextfile(FileName)
    objcsv.writeline ("DisplayName,LegacyDN,Server,Database,TotalItems,Size(MB)")
    For Each strComputer In arrComputers
    	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftExchangeV2")
    	Set colItems = objWMIService.ExecQuery("SELECT * FROM Exchange_Mailbox", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
    	For Each objItem In colItems
    		SizeinMB = Round(objItem.Size / 1024, 2)
    		objcsv.writeline (q & objItem.MailboxDisplayName & q & "," & q & objItem.LegacyDN & q & "," & q & objItem.ServerName & q & "," & q & objItem.StoreName & q & "," & q & objItem.TotalItems & q & "," & q & SizeinMB & q)
    Set objFSO = nothing
    Set objWMIService = nothing
    Set colItems = nothing
    'Create link to CDOmail
    Set objMsg        = CreateObject("CDO.Message")
    'Enter subject of message in quotes
    objMsg.Subject  = "Automated Message:  Exchange 2003 Data Report for " & Date()
    'Enter email address of sender within quotes ie
    objMsg.From = "noreply@domain.com"
    'Enter destination email address in quotes.
    objMsg.To = "recipient@domain.com"
    'Set the message body
    objMsg.TextBody = "Automated query executed from the 'Exch2003Stats_RunThis' scheduled task on zexowat02.zachry.com."
    'Add the attachment
    objMsg.AddAttachment "D:\scripts\Exch2003Stats.csv" 
    'Setup the server to send the email through
    objMsg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objMsg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Servername.domain.com" 
    objMsg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    'Send the message

    Bobby Pendino

    Tuesday, July 8, 2014 4:43 PM


  • Hi Bobby,

    Sorry for my lack knowledge about script and code. According to your description, I understand that you are using a script to get all mailboxes size and target address information from Exchange 2003. For more professional suggestions, I recommend you can also ask a question in Script Center for more help:


    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Sorry for any inconvenience and thanks for your understanding.


    Winnie Liang
    TechNet Community Support

    Wednesday, July 9, 2014 12:46 PM