VBScript to read Exchange 2003 mailbox store total size

VBScript to read Exchange 2003 mailbox store total size

Door: Arnout van der Vorst

In Exchange 2007, you have PowerShell to perform powerful queries on mailbox stores, which make it easy to get the total size of a mailbox store by calculating all mailbox contents in bytes. In Exchange 2003 however, you need to do this with WMI which doesn’t know about mailbox stores but only allows you to query mailboxes.

The script below does 2 loops through all mailboxes. The first one is to get a unique list of all the mailbox stores from each mailbox, and the second one is to calculate the total size of each unique mailbox store from all the mailboxes. In my tests it takes about 30 seconds for an environment of 3 mailbox stores with over 9000 mailboxes.
The script takes 2 parameters, Exchange server and output file. The output file will contain the following data:
mailbox store 1|5262342
mailbox store 2|23489
mailbox store 3|60930235
==========================================
dim fso, StoreArray, StoreName_cache
set fso = CreateObject(“Scripting.FileSystemObject”)
strComputerName = wscript.arguments(0)
strOutput = wscript.arguments(1)
set output = fso.CreateTextFile(strOutput, True)
strE2K3WMIQuery = “winmgmts://” & strComputerName & “/root/MicrosoftExchangeV2”
Set mboxList = GetObject(strE2K3WMIQuery).InstancesOf(“Exchange_Mailbox”)
StoreName_cache = “”
For each mailbox in mboxList
if InStr(StoreName_cache, mailbox.StoreName) = 0 then
StoreName_cache = StoreName_cache & “;” & mailbox.StoreName & “|0”
end if
Next
StoreName_cache = Mid(StoreName_cache, 2, Len(StoreName_cache))
StoreArray = Split(StoreName_cache, “;”)
For each mailbox in mboxList
For currentIndex = 0 to UBound(StoreArray)
tmpArray = Split(StoreArray(currentIndex), “|”)
if tmpArray(0) = mailbox.StoreName then
tmpSize = CLng(tmpArray(1)) + CLng(mailbox.Size)
StoreArray(currentIndex) = mailbox.StoreName & “|” & tmpSize
end if
Next
Next
For currentIndex = 0 to UBound(StoreArray)
output.WriteLine StoreArray(currentIndex)
Next
Arnout van der Vorst

Geschreven door:
Arnout van der Vorst

Maak kennis met Arnout van der Vorst, de inspirerende Identity Management Architect bij Tools4ever sinds het jaar 2000. Na zijn studie Hogere Informatica aan de Hogeschool van Utrecht is hij begonnen als Supportmedewerker bij Tools4ever. Daarna heeft Arnout zich opgewerkt tot een sleutelfiguur in het bedrijf.  Zijn bijdragen strekken zich uit van klantondersteuning tot strategische pre-sales activiteiten, en hij deelt zijn kennis via webinars en artikelen.

Anderen bekeken ook

SAP koppeling met Active Directory

SAP koppeling met Active Directory

06 september 2012

User- en toegangsbeheer in cloud applicaties: een uitdaging

User- en toegangsbeheer in cloud applicaties: een uitdaging

04 september 2012

De vooroordelen van Single Sign On

De vooroordelen van Single Sign On

29 november 2011

RBAC: sleutelrol, beheer en evolutie

RBAC: sleutelrol, beheer en evolutie

15 maart 2011

Single Sign On met terminal emulatie (VAX64, AS/400, Linux, SSH)

Single Sign On met terminal emulatie (VAX64, AS/400, Linux, SSH)

14 oktober 2010