Mailbox Sizes Exchange 2003 (VBScript)

AddThis Social Bookmark Button

This script produces a summary of mailbox sizes on an Exchange 2003 server.

This includes; Server Name,Storage Group,User Display Name,Mailbox Size,Total Items,Deleted Items Size.

Simply copy and paste the following code into notepad and save the file as exchange.vbs. When you run this script a file called MailBoxSize.txt will be created in the same location as the script.

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_Mailbox")
   
dim str
dim header
header = "Server Name,Storage Group,User Display Name,Mailbox Size,Total Items,Deleted Items Size"
For Each objItem in colItems
    str = str & objItem.ServerName & ","
    str = str & objItem.StorageGroupName & ","
    str = str & objItem.MailboxDisplayName & ","
    str = str & objItem.Size & ","
    str = str & objItem.TotalItems & ","
    str = str & objItem.DeletedMessageSizeExtended
    str = str & VbCrLf
Next

dim fso
set fso = CreateObject("Scripting.FileSystemObject")
set file = fso.CreateTextFile(".\MailBoxSize.txt", True)


file.WriteLine(header)
file.WriteLine(str)
file.Close