Home » VBScript to Enumate Exchange Mailbox sizes

Google
 

VBScript to Enumate Exchange Mailbox sizes


The following vbscript can be used to enumerate the size of mailboxes in an MS Exchange environment:

On Error Resume Next

Dim arrMBX(10,3)
Dim TotalMailboxes

For intElement = 1 To 10
arrMBX(intElement,2) = 0
Next

TotalMailboxes = 0
TopMBSize = 0
LastMBsize = 0

strComputer = InputBox(”Enter the name of the Exchange Server?”,”Top Mailbox Offenders”)
Set objWMIService = GetObject(”winmgmts:{impersonationLevel=impersonate}!\\” & strComputer & “\ROOT\MicrosoftExchangeV2″)
Set colMailboxes = objWMIService.ExecQuery (”Select * from Exchange_Mailbox”)

For Each objMB in colMailboxes
strMBox = objMB.MailboxDisplayName
intSize = objMB.Size
intItem = objMB.Item
If intSize > LastMBSize Then
intElement = 0
ShiftArray strMBox, intSize, intItem
TopMBSize = arrMBX(1,2)
LastMbSize = arrMBX(10,2)
End if
Next

DisplayResults

Sub ShiftArray (Mbox,iSize,iItems)
intSpot = 1
For intPtr = 1 To 10
If arrMBX(intPtr,2)+1 <= iSize+1 Then
intSpot = intPtr
intPtr = 11
End if
Next
For intPtr = 9 To intSpot Step -1
arrMBX(intPtr+1,1) = arrMBX(intPtr,1)
arrMBX(intPtr+1,2) = arrMBX(intPtr,2)
arrMBX(intPtr+1,3) = arrMBX(intPtr,3)
next
arrMBX(intSpot,1) = Mbox
arrMBX(intSpot,2) = iSize
arrMBX(intSpot,3) = iItem
End sub

Sub DisplayResults
For intElement = 1 To 10
WScript.Echo intElement & “. ” & left(arrMBX(intElement,1) & Space(30),30) & ” - ” & FormatNumber(arrMBX(intElement,2),0,0,-1)
Next
End sub

Leave a Reply

Links: More at WindowsWideOpen.com

powered by FreeFind