使用此脚本可以输入组织名称和Exchange存储对象的数量。
'Outputs the current number of objects
'in each of the stores in the organization.
'Useful for load balancing mailboxes across
'servers and such.
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Dim arrStores()
intStores = 0
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT distinguishedName FROM 'LDAP://CN=Administrative Groups,CN=YourOrgName,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=Contoso,DC=Com' WHERE " _
& "objectClass = 'msExchPrivateMDB'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
ReDim Preserve arrStores(intStores)
arrStores(intStores) = "LDAP://" & objRecordSet.Fields("distinguishedName").Value
intStores = intStores + 1
objRecordSet.MoveNext
Loop
For Each strStore in arrStores
intMembers = 0
Set objStore = GetObject(strStore)
arrMembers = objStore.GetEx("homeMDBBL")
For Each strMember in arrMembers
intMembers = intMembers + 1
Next
WScript.Echo objStore.Name & " has " & intMembers & " objects."
Next