' This script was originally published in the Exchange Cookbook, ' (http://www.exchangebookcook.com). Written by Paul Robichaux, ' Missy Koslosky, and Devin Ganger. Redistributed with permission ' of the publisher, O'Reilly & Associates. ' This script enumerates all the mailboxes in each database in each ' storage group. ' ------ SCRIPT CONFIGURATION ------ strBase = ";" ' " ' "batman" strComputerName = "batman" strAttrs = "cn;" strScope = "subtree" ' ------ END CONFIGURATION --------- set theServer = CreateObject("CDOEXM.ExchangeServer") Set theSG = CreateObject("CDOEXM.StorageGroup") Set theConn = CreateObject("ADODB.Connection") theConn.Open "Provider=ADsDSOObject;" theServer.DataSource.Open strComputerName ' examine the SGs; for each SG, iterate through its databases and ' list the mailboxes in it For Each sg In theServer.StorageGroups WScript.Echo "Storage group " & Chr(34) & sg & Chr(34) theSG.DataSource.open sg i = 0 For Each mailDB In theSG.MailboxStoreDBs i = i+1 WScript.Echo " Mailbox database " & i & ": " & mailDB wscript.Echo " Users: " Set objRS = theConn.Execute(strBase & "(homeMDB=" & mailDB & ");" & strAttrs & strScope) objRS.MoveFirst While Not objRS.EOF wscript.echo " " & objRS.Fields(0).Value objRS.MoveNext Wend wscript.echo Chr(13) & Chr(13) Next Next