Welcome to TechNet Blogs Sign in | Join | Help

Exchange: number of mailboxes per information store

I blogged about how to find out mailbox use using MOM and the management pack the other week but if you don't have MOM in your environment this doesn't help you much.  So I did some digging and found out that you can return information about the Exchange store using WMI and the Exchange_Mailbox class from the Exchange 2003 SDK.

here's an example of the VB script (copied from the SDK, not created by me!)

The following example shows how to retrieve a list of Exchange_Mailbox instances, and how to retrieve all the associated properties.

'===============================================================
 ' Purpose: Display each Exchange_Mailbox found for Exchange server, ' and show all properties 
on the Exchange_Mailbox ' objects ' 
Change: cComputerName [string] the computer to access ' 
Output: Displays the name of each Exchange_Mailbox and properties 
'=============================================================== 
On Error Resume Next 
Dim cComputerName 
Const cWMINameSpace = "root/MicrosoftExchangeV2" 
Const cWMIInstance = "Exchange_Mailbox" 
cComputerName = "MyComputerNETBIOSName" 
 
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 
Wscript.Echo"" 
Wscript.Echo"" 
' 
' Display the value of the AssocContentCount property. 
WScript.echo "AssocContentCount = "& _ 
" ["&TypeName(objExchange_Mailbox.AssocContentCount)&"] "& _ 
objExchange_Mailbox.AssocContentCount 
' 
' 
' Display the value of the DateDiscoveredAbsentInDS property. 
WScript.echo "DateDiscoveredAbsentInDS = "& _ 
" ["&TypeName(objExchange_Mailbox.DateDiscoveredAbsentInDS)&"] "& _ 
objExchange_Mailbox.DateDiscoveredAbsentInDS 
' 
' 
' Display the value of the DeletedMessageSizeExtended property. 
WScript.echo "DeletedMessageSizeExtended= "& _ 
" ["&TypeName(objExchange_Mailbox.DeletedMessageSizeExtended)&"] "& _ 
objExchange_Mailbox.DeletedMessageSizeExtended 
' 
' 
' Display the value of the LastLoggedOnUserAccount property. 
WScript.echo "LastLoggedOnUserAccount = "& _ 
" ["&TypeName(objExchange_Mailbox.LastLoggedOnUserAccount)&"] "& _ 
objExchange_Mailbox.LastLoggedOnUserAccount 
' 
' 
' Display the value of the LastLogoffTime property. 
WScript.echo "LastLogoffTime = "& _ 
" ["&TypeName(objExchange_Mailbox.LastLogoffTime)&"] "& _ 
objExchange_Mailbox.LastLogoffTime 
' 
' 
' Display the value of the LastLogonTime property. 
WScript.echo "LastLogonTime = "& _ 
" ["&TypeName(objExchange_Mailbox.LastLogonTime)&"] "& _ 
objExchange_Mailbox.LastLogonTime 
' 
' 
' Display the value of the LegacyDN property. 
WScript.echo "LegacyDN = "& _ 
" ["&TypeName(objExchange_Mailbox.LegacyDN)&"] "& _ objExchange_Mailbox.LegacyDN 
' 
' 
' Display the value of the MailboxDisplayName property. 
WScript.echo "MailboxDisplayName = "& _ 
" ["&TypeName(objExchange_Mailbox.MailboxDisplayName)&"] "& _ 
objExchange_Mailbox.MailboxDisplayName 
' 
' 
' Display the value of the MailboxGUID property.
WScript.echo "MailboxGUID = "& _ 
" ["&TypeName(objExchange_Mailbox.MailboxGUID)&"] "& _ 
objExchange_Mailbox.MailboxGUID 
' 
' 
' Display the value of the ServerName property. 
WScript.echo "ServerName = "& _ 
" ["&TypeName(objExchange_Mailbox.ServerName)&"] "& _ 
objExchange_Mailbox.ServerName 
' 
' 
' Display the value of the Size property. 
WScript.echo "Size = "& _ 
" ["&TypeName(objExchange_Mailbox.Size)&"] "& _ 
objExchange_Mailbox.Size 
' 
' 
' Display the value of the StorageGroupName property. 
WScript.echo "StorageGroupName = "& _ 
" ["&TypeName(objExchange_Mailbox.StorageGroupName)&"] "& _ 
objExchange_Mailbox.StorageGroupName 
' 
' 
' Display the value of the StorageLimitInfo property. 
WScript.echo "StorageLimitInfo = "& _ 
" ["&TypeName(objExchange_Mailbox.StorageLimitInfo)&"] "& _ 
objExchange_Mailbox.StorageLimitInfo 
' 
' 
' Display the value of the StoreName property. 
WScript.echo "StoreName = "& _ 
" ["&TypeName(objExchange_Mailbox.StoreName)&"] "& _ 
objExchange_Mailbox.StoreName 
' 
' 
' Display the value of the TotalItems property. 
WScript.echo "TotalItems = "& _ 
" ["&TypeName(objExchange_Mailbox.TotalItems)&"] "& _ 
objExchange_Mailbox.TotalItems 
' 
Next 
Else 
' If no Exchange_Mailbox instances were returned, 
' display that. 
WScript.Echo "WARNING: No Exchange_Mailbox instances were returned." 
End If 
End If
 

 

Published Monday, March 07, 2005 6:59 PM by Eileen_Brown
Filed Under: , , ,

Comments

No Comments
New Comments to this post are disabled