fullname = "testing" strComputerName = "MAIL" '''''''''''' ''' DOING MAIL STORE WORK '' '' ' ' need to get the storage group from teh list for fullname ' This script lists all of the storage groups on the specified server. ' For each SG, it lists information on the SG, including its ' database stores and their paths. set theServer = CreateObject("CDOEXM.ExchangeServer") Set theSG = CreateObject("CDOEXM.StorageGroup") Set thePF = CreateObject("CDOEXM.PublicStoreDB") Set theMB = CreateObject("CDOEXM.MailboxStoreDB") theServer.DataSource.Open strComputerName ' examine the SGs; for each SG, list its associated stores and paths For Each sg In theServer.StorageGroups theSG.DataSource.open sg i = 0 For Each mailDB In theSG.MailboxStoreDBs '---- tpos=InStr(1,mailDB,fullname,0) 'wscript.echo tpos if tpos = "4" then wscript.echo "mail box userpath is value mailDB " & mailDB else end if i = i+1 ' ' ' ' WScript.Echo mailDB theMB.DataSource.open mailDB Next i = 0 For Each pubDB In theSG.PublicStoreDBs i = i+1 Next Next ' This code uses WMI to interrogate the Exchange routing table ' and list all known Exchange servers. ' ------ END CONFIGURATION --------- strE2KWMIQuery = "winmgmts://" & strComputerName &_ "/root/cimv2/applications/exchange" strE2K3WMIQuery = "winmgmts://" & strComputerName &_ "/root/MicrosoftExchangeV2" ' display basic attributes using Exchange 2000 WMI provider set serverList = GetObject(strE2KWMIQuery).InstancesOf("ExchangeServerState") for each ExchangeServer in serverList strServer=ExchangeServer.Name 'SGReport strServer 'Sub SGReport(strServer) Dim iServer Dim iSGs Dim iMBS Set iServer=CreateObject("CDOEXM.ExchangeServer") Set iSGs=CreateObject("CDOEXM.StorageGroup") Set iMBs=CreateObject("CDOEXM.MailboxStoreDB") iServer.DataSource.Open strServer arrSGs=iServer.StorageGroups For i=0 To UBound(arrSGs) strSGUrl=arrSGs(i) iSGs.DataSource.Open "LDAP://" & iServer.DirectoryServer & "/" & strSGUrl ' strData=strData & iSGs.Name & vbcrlf arrMBStores=iSGs.MailboxStoreDBs For j=0 To UBound(arrMBStores) iMBS.DataSource.open "LDAP://" & arrMBStores(j) strData=strData & vbTab & iMBS.Name& vbcrlf Next Next pos=InStr(1,strData,fullname,0) 'wscript.echo strData 'wscript.echo pos '----- if pos = "0" then ' if pos = "344" then wscript.echo "store not found - creating mail store" strMailStoreName = fullname strSGName = fullname strServer = "MAIL" strNewSG="sg1" CreateNewStorageGroup strNewSG,strServer strNewSG="sg2" CreateNewStorageGroup strNewSG,strServer strNewSG="sg3" CreateNewStorageGroup strNewSG,strServer strNewSG="sg4" CreateNewStorageGroup strNewSG,strServer Sub CreateNewStorageGroup(strSGName,strComputerName) ' Dim iServer Dim iStGroup Dim strTemp Set iServer=CreateObject("CDOEXM.ExchangeServer") Set iStGroup=CreateObject("CDOEXM.StorageGroup") ' Set the name of the StorageGroup iStGroup.Name = strSGName ' Bind to the Exchange Server iServer.DataSource.Open strComputerName For Each sg In iServer.StorageGroups strTemp = sg Exit For Next 'cut out the Storage Group name from URL strTemp = Mid(strTemp, InStr(2, strTemp, "CN")) ' Build the URL to the StorageGroup strSGUrl = "LDAP://" & iServer.DirectoryServer & "/CN=" & strSGName & "," & strTemp ' WScript.Echo "Creating " & strSGUrl ' Save the StorageGroup iStGroup.DataSource.SaveTo strSGUrl ' This code creates a Mailbox Store. ' ' Find Storage Group URL strSearch = "CN=" & strSGName & "," set objSrv = CreateObject("CDOEXM.ExchangeServer") objSrv.DataSource.Open strServer for each strSg in objSrv.StorageGroups if (instr(1,strSg,strSearch,1)>0) then strSGUrl = strSg next ' Generate Mailbox Store URL strMBUrl = "LDAP://CN=" & strMailStoreName & "," & strSGUrl ' Create/configure Mailbox Store and save it set objMb = CreateObject("CDOEXM.MailBoxStoreDB") objMb.DataSource.SaveTo strMBUrl ' Mount DataBase objMB.Mount Wscript.Echo "Created mailbox store." ' 'Set permission on mailbox store - strMBUrl ' 'strMBUrl ' ' This code mounts a Mailbox Store. ' Find Storage Group URL strSearch = "CN=" & strSGName & "," set objSrv = CreateObject("CDOEXM.ExchangeServer") objSrv.DataSource.Open strServer for each sg in oSrv.StorageGroups if (instr(1,sg,strSearch,1)>0) then strSGUrl = sg next ' Generate Mailbox Store URL strMBUrl = "LDAP://CN=" & strMailStoreName & "," & strSGUrl ' Open Mailbox Store set objMb = CreateObject("CDOEXM.MailBoxStoreDB") objMb.DataSource.Open strMBUrl 'wscript.echo strMBUrl if (objMb.Status = 0) then else ' Wscript.Echo "Mailbox store is dismounted, mounting..." objMb.Mount end if Wscript.Echo "Mounted Mailbox store" Else wscript.echo "store already found" '----- End if Next