Set objArgs = Wscript.Arguments If objArgs.Count < 3 Then WScript.Echo "You have not supplied the correct number of arguments - this script requires amd Log File " Wscript.Quit End if strStoreCN = objArgs(0) strMTAcn = objArgs(1) strPathToLog = objArgs(2) Const WMINameSpace = "root/MicrosoftExchangeV2" Const WMIInstance = "Exchange_Mailbox" Set wshNetwork = WScript.CreateObject("WScript.Network") Set WshShell = WScript.CreateObject("WScript.Shell") ComputerName = wshNetwork.computerName Sub LoggingCommand(strEvent,strDest) nReturnCode = wshShell.Run("cmd /c @echo " & strEvent & " >>" & strDest, 1, TRUE) End Sub LoggingCommand "********************************************************************************",strPathToLog LoggingCommand "* Cluster to Basic - Store Sync Tool - New Session: " & Date,strPathToLog LoggingCommand "********************************************************************************",strPathToLog LoggingCommand " ",strPathToLog Set oIADS = GetObject("LDAP://RootDSE") strConfContext= "LDAP://" & oIADS.Get("defaultNamingContext") Set objCommand = CreateObject("ADODB.Command") Set objConn = CreateObject("ADODB.Connection") LoggingCommand "Connecting to Active Directory context: " & strConfContext,strPathToLog strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName&"/"& WMINameSpace Set objWMIExchange = GetObject(strWinMgmts) LoggingCommand "Connecting to WMI Namespace: " & strWinMgmts,strPathToLog Set listExchangeMBMailbox = objWMIExchange.InstancesOf(WMIInstance) LoggingCommand "Enumerating Mailboxes....",strPathToLog If (listExchangeMBMailbox.count > 0) Then For Each objExchange_Mailbox in listExchangeMBMailbox strDN = objExchange_Mailbox.LegacyDN objConn.Open "Provider=ADsDSOObject;" Set objCommand.ActiveConnection = objConn objCommand.CommandText = "SELECT distinguishedName FROM "+"'"+strConfContext+"'"+" WHERE legacyExchangeDN = '" & strDN & "'" objCommand.Properties("searchscope") = 2 objCommand.Properties("Page Size") = 1000 Set objRecordSet = objCommand.Execute Set objUser = GetObject("LDAP://" & objRecordSet.Fields("distinguishedName")) LoggingCommand "Working with user: " & objUser.distinguishedName,strPathToLog On error resume next objUser.homeMDB = strStoreCN objUser.HomeMTA = strMTAcn LoggingCommand "Setting Attributes homeMDB: " & strStoreCN,strPathToLog LoggingCommand "Setting Attributes homeMTA: " & strMTACN,strPathToLog LoggingCommand " ",strPathToLog objUser.SetInfo If Err <> 0 Then LoggingCommand "An Error occured: " & err.description,strPathToLog End if objConn.Close Next End If LoggingCommand "Processing has completed.",strPathToLog LoggingCommand "---------------------------------------------------------------------------- OK - version 1.0.34",strPathToLog