Those of you that have been following this blog will know that recently I have made a number of posts that are either based around the virtues of Test Labs or indeed that work that I have been doing in relation to them – for information my posts on the subject are here, here, here, here and finally here.
Now one of the most daunting things about test labs, is not always the construction of the Domain, or indeed the creation of the servers within them, but how to you populate them with any meaningful user data as part of the Directory (e.g. creating a number of users).
In this article I would like to provide all of you with the following tools that will help you construct the users in your test lab:
strCSVPath = InputBox(”Please enter in the full path to your CSV (PLEASE INCLUDE THE END SLASH \)”)
strCSVName = InputBox(”Please Enter in the FileName”)
strOU = InputBox(”Please Enter in the destination OU (FORMAT: OU=,OU=”)
set csvInputConn = createobject(”ADODB.connection”)
set csvInputRS = createobject(”ADODB.recordset”)
csvInputRS.open “SELECT * FROM ” & strCSVName,csvInputConn
Set RootLDAP = GetObject(”LDAP://rootDSE“)
Set ADLocation = GetObject(”LDAP://” & strOU & “,” & RootLDAP.Get(”defaultNamingContext”))
do until csvInputRS.EOF
On Error Resume Next
strFirstName = csvInputRS.Fields.Item(0).value
strSurName = csvInputRS.Fields.Item(1).value
strSam = csvInputRS.Fields.Item(2).value
strDisplayName = csvInputRS.Fields.Item(3).value
strPassword = csvInputRS.Fields.Item(4).value
strUPN = csvInputRS.Fields.Item(5).value
Set strUser = ADLocation.Create(”User”,”cn=” & strSam)
strUser.Put “userAccountControl”, 512
WScript.Echo “Script Completed - Hit F5 in the OU that you selected”
A long time ago I posted a VBSCRIPT and CSV file which when executed created over 300 user accounts in Active Directory which was designed to give you a number of test accounts which could be used within a LAB environment to test Exchange Server.
As mentioned the original script was based around VBSCRIPT and Exchange 2003 and also required a little bit of manual intervention in order for it to work within your specific environment.