' 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 creates a new mailbox database at the specified
' location
' ------ SCRIPT CONFIGURATION ------
strServerName = "<serverName>" ' e.g. "BATMAN"
strDBName = "<newMDBName>" ' e.g. "SpiffyNewMDB"
' ------ END CONFIGURATION ---------
Set theServer = CreateObject("CDOEXM.ExchangeServer")
Set theMDB = CreateObject("CDOEXM.MailboxStoreDB")
' bind to the Exchange server and build the database URL
theServer.DataSource.Open strServerName
'Get the array list of StorageGroups and turn it into a
'target SG name. If you want this in another SG, modify
'the code to get the correct one either by name or by index.
strTemp = theServer.StorageGroups
strTemp1 = Mid(strTemp(0), InStr(2, strTemp(0), "CN"))
theFirstSG = "CN=" & "First Storage Group" & "," & strTemp1
strURL = "LDAP://" & theServer.DirectoryServer & "/cn=" & strDBName & "," & theFirstSG
theMDB.Name = strDBName
theMDB.DataSource.SaveTo strURL
WScript.Echo "Created new MDB " & strDBName & " at " & strURL
theMDB.Mount
WScript.Echo "Mounted new MDB " & strDBName
|