Dim oIADSUser Dim oMailbox strOU = InputBox("Please Enter in the path to the OU where you users are located:") strStore = InputBox("Please type in the name of the store that you wish to place the mailboxes in") Set NC = GetObject("LDAP://RootDSE") Set oIADS = GetObject("LDAP://RootDSE") strConfContext = NC.Get("defaultnamingcontext") strADSPath = "LDAP://" & strOU & "," & oIADS.Get("defaultNamingContext") Set objCommand = CreateObject("ADODB.Command") Set objConn = CreateObject("ADODB.Connection") objConn.Open "Provider=ADsDSOObject;" Set objCommand.ActiveConnection = objConn objCommand.CommandText = "SELECT distinguishedName FROM "+"'"+strADsPath+"'"+" WHERE objectClass = 'user'" objCommand.Properties("searchscope") = 2 objCommand.Properties("Page Size") = 1000 Set objRecordSet = objCommand.Execute While Not objRecordSet.EOF Set oIADSUser = GetObject("LDAP://" & objRecordSet.Fields("distinguishedName")) Set oMailBox = oIADSUser oMailbox.CreateMailbox FindAnyMDB("CN=Configuration," & strConfContext) oIADSUser.SetInfo objRecordSet.MoveNext Wend Function FindAnyMDB(strConfigurationNC) Dim oConnection Dim oCommand Dim oRecordSet Dim strQuery Set oConnection = CreateObject("ADODB.Connection") set oCommand = CreateObject("ADODB.Command") Set oRecordSet = CreateObject("ADODB.Recordset") oConnection.Provider = "ADsDSOObject" oConnection.Open "ADs Provider" strQuery = ";(Name=" & strStore & ");name,adspath;subtree" oCommand.ActiveConnection = oConnection oCommand.CommandText = strQuery Set oRecordSet = oCommand.Execute If Not oRecordSet.EOF Then oRecordSet.MoveFirst FindAnyMDB = CStr(oRecordSet.Fields("ADsPath").Value) Else FindAnyMDB = "" End If oRecordSet.Close oConnection.Close Set oRecordSet = Nothing Set oCommand = Nothing Set oConnection = Nothing End Function Wscript.Echo "Script Completed"