Script to Extract Mailbox sizes from Exchange 2003
Helping to migrate a customer from 2003 to 2013 (via 2010) I was required to pull of a list of mailbox sizes and couldn't find a single script that did the trick in one hit- so I've stuck together the elements of this http://www.msexchange.org/articles-tutorials/exchange-server-2003/tools/Scripting-Exchange-VBScript-ADSI-Part3.html (which, for reasons beyond my understanding, outputs to screen- pretty useless) with an out put to text - for ease of reference I've posted it here!
On Error Resume Next Dim cComputerName Const cWMINameSpace = "root/MicrosoftExchangeV2" Const cWMIInstance = "Exchange_Mailbox" cComputerName = "BR-SRV-DC01" Set objFSO=CreateObject("Scripting.FileSystemObject")
Dim strWinMgmts ' Connection string for WMI Dim objWMIExchange ' Exchange Namespace WMI object Dim listExchange_Mailboxs ' ExchangeLogons collection Dim objExchange_Mailbox ' A single ExchangeLogon WMI object
' Create the object string, indicating WMI (winmgmts), using the ' current user credentials (impersonationLevel=impersonate), ' on the computer specified in the constant cComputerName, and ' using the CIM namespace for the Exchange provider. strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//"& _ cComputerName&"/"&cWMINameSpace Set objWMIExchange = GetObject(strWinMgmts) ' Verify we were able to correctly set the object. If Err.Number 0 Then WScript.Echo "ERROR: Unable to connect to the WMI namespace." Else ' ' The Resources that currently exist appear as a list of ' Exchange_Mailbox instances in the Exchange namespace. Set listExchange_Mailboxs = objWMIExchange.InstancesOf(cWMIInstance) ' ' Were any Exchange_Mailbox Instances returned? If (listExchange_Mailboxs.count > 0) Then ' If yes, do the following: ' Iterate through the list of Exchange_Mailbox objects. For Each objExchange_Mailbox in listExchange_Mailboxs ' ' Display the value of the Size property. ' WScript.echo objExchange_Mailbox.MailboxDisplayName & "," & objExchange_Mailbox.Size ' Add item to file outFile="c:\mailboxes.txt" Set objFile = objFSO.CreateTextFile(outFile,True) objFile.Write objExchange_Mailbox.MailboxDisplayName & "," & objExchange_Mailbox.Size & vbCrLf ' objFile.Close ' Next Else ' If no Exchange_Mailbox instances were returned, ' display that. WScript.Echo "WARNING: No Exchange_Mailbox instances were returned." End If End If