Exchange 2003: Returning mailbox sizes
This script uses WMI and Active Directory queries to return information about mailbox sizes from Exchange and the limits set in Active Directory.
Download GetMailboxStatistics.vbs
A number of people have been looking for Get-MailboxStatistics for Exchange 2003. I have a PowerShell version of this script for exactly that reason here.
This script is only intended for use with Exchange 2003. Exchange 2000 must use MAPI, Exchange 2007 has a PowerShell cmdlet, Get-MailboxStatistics, which can much more easily return this information.
It requires access to WMI on each Exchange Server, but does not require any of the Exchange System Tools. legacyExchangeDN is used to match accounts between AD and Exchange.
The script performs a number of searches in Active Directory. The largest number if multiple Admin Groups are selected (/a:”Admin Group*”). It can be instructed to use a single DC by specifying a name with the /dc switch. For forest-wide searches that must be a Global Catalog. If no DC is specified the script executes a DNS query for Global Catalog service records on the current forest name to attempt to find a (responding) GC in the current site, failing back to any GC in the forest otherwise.
Usage
cscript GetMailboxStatistics.vbs [/o] [/s:<exchangeServer>]
[/a:"<administrative Group Name>"] [/d:<domainName>]
[/dc:<domainControllerName>] [/f:<fileName>]
One of the following parameters must be specified:
/o Get statistics from all Exchange Servers in the organisation
This option overrides all others
/s Get statistics for this Exchange Server only
This option overrides all except /o
/a Get statistics from all Exchange Servers in the specified Administrative Group
/d Get statistics from all Exchange Servers in the specified Domain
The following parameters are optional:
/dc A Domain Controller to use for this process. Must be a Global Catalog
for reporting that covers a Forest. The script will attempt to find a
GC in the current site if not specified.
/f File Name for the output. Default file name is MailboxReport.csv
The following details are returned by this script:
- Name
- DN
- AccountStatus (Enabled / Disabled)
- UseDefaultQuotas (True / False)
- Warn (in Mb, Warning Limit if specified on User Account)
- ProhibitSend (in Mb, if specified on User Account)
- ProhibitSendAndReceive (in Mb, if specified on User Account)
- Size (in Mb)
- TotalItems
- MailboxStatus (BelowLimit, IssueWarning, ProhibitSend, NoChecking, MailboxDisabled)
- AssocContentCount (Total Number of messages associated with the mailbox folders)
- DeletedMessageSize (in Mb)
- LastLoggedOnUser
- LastLogon
- LastLogoff
- DateDeleted (for mailboxes which have been disconnected, waiting to be purged)
- MailboxDisplayName
- MailboxGuid
- ServerName (Exchange Server)
- StorageGroup
- Store
- legacyExchangeDN
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
Posted by Zygi on 28.10.08 at 12:13 pm
Modified, to show LastLogon info instead of StoreLimits.
Code snipped. Main script has been updated to include LastLogon and all other interesting WMI attributes. Chris
Posted by Chris on 28.10.08 at 12:13 pm
Edited to add code-formatting / remove HTML tags, thanks Zygi :)
Chris
Posted by Mark on 28.10.08 at 12:13 pm
Hi, when i run this i get the error
D:\E2K3 SG Size\GetStoreLimits.vbs(21, 60) Microsoft VBScript compilation error:
Expected ‘)’
i presume i am doing something very silly
Posted by Chris on 28.10.08 at 12:13 pm
Nope, not you. It looks like the code isn’t displaying properly after I updated the code formatting plug-in. I’ve changed it to a text attachment which should work better.
Chris
Posted by Shogan on 28.10.08 at 12:13 pm
Hi there,
Got the script and wanted to test it on my exchange server – I see I need the exchange system tools. Does anyone have a download link to these? From what I can see MS doesn’t offer this as a complete packaged download anymore, only individual downloads for each tool…
Posted by Chris on 28.10.08 at 12:13 pm
No tools necessary, this version uses WMI to grab the information from Exchange, everything else comes from Active Directory.
Chris
Posted by Shogan on 28.10.08 at 12:13 pm
Ok so I copy-pasted your code into textpad, saved as mailboxes.vbs double-clicked, but it gives an error on line 137, character 51. Expected “)”
Any ideas? Do I need to run it from a specific location?
Posted by Chris on 28.10.08 at 12:13 pm
The version from the linked text file at the top? Can’t reproduce the error with that one.
Chris
Posted by Matt on 28.10.08 at 12:13 pm
Hi there,
I ran into a problem running the script. Am I doing something wrong? When I run the following:
cscript getmailboxstatistics.vbs /s:exchange1
It returns this error:
getmailboxstatistics.vbs(168, 5) Microsoft VBScript runtime error: This key is already associated with an element of this collection
thanks for your help!
Matt
Posted by Chris on 28.10.08 at 12:13 pm
If you’re supplying a server name it should only be looking for users, which suggests that you have a user with a duplicate LegacyExchangeDN (because that’s the Key).
On the line above 168, add “WScript.Echo strKey”, then it’ll echo out every key it’s trying to store.
Chris