' 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 code creates a new user mailbox, then mail-enables ' it by creating a mailbox in the first MDB on the server. ' ------ SCRIPT CONFIGURATION ------ strDCName = "" ' e.g. "" strUserName = "" ' e.g. "jrandomuser" strFirstName = "Joe" strLastName = "Blow" strPassword = "G0bbeldygook!#" ' ------ END CONFIGURATION ------ Set oIADS = GetObject("LDAP://RootDSE") strDefaultNC = oIADS.Get("defaultnamingcontext") strConfigNC = oIADS.Get("configurationNamingContext") strContainer= "/CN=Users," & strDefaultNC Set objContainer = GetObject("LDAP://" & strDCName & strContainer) Set NewUser = objContainer.Create("User", "cn=" & strUserName) With NewUser .firstName = strFirstName .lastName = strLastName .Put "sAMAccountName", strUserName .SetInfo End With With NewUser .AccountDisabled = False .SetPassword strPassword .SetInfo End With ' Open the connection. Set theConnection = CreateObject("ADODB.Connection") set theCommand = CreateObject("ADODB.Command") Set theRecordSet = CreateObject("ADODB.Recordset") theConnection.Provider = "ADsDSOObject" theConnection.Open "ADs Provider" ' Build the query to find the private MDBs. Use the first ' one if any are found. strQuery = ";(objectCategory=msExchPrivateMDB);name,adspath;subtree" theCommand.ActiveConnection = theConnection theCommand.CommandText = strQuery Set theRecordSet = theCommand.Execute If Not theRecordSet.EOF Then theRecordSet.MoveFirst firstMDB = CStr(theRecordSet.Fields("ADsPath").Value) Else firstMDB = "" End If ' create the mailbox With NewUser .CreateMailbox firstMDB .SetInfo End With WScript.Echo "Mailbox created successfully"