This script is fairly basic. We have a temporary(7-12 month) program coming in and they need their own domain. They won’t have exchange or really need AD for anything except authentication and GPOs. This was made for server 2008, but everything works on 2000/2003. We got a list of 85 names for user accounts in a text file, so this is how i used them for input. anyway, here it is:
Option Explicit
Const ADS_PROPERTY_APPEND = 3 'sets the variable to Append
Const ADS_UF_NORMAL_ACCOUNT = 512
Const ForReading = 1
Dim strcontainer, strUser, i, objRootDSE, strDisplayName, ObjFSO, objInFile, objContainer, strLine, strName, objOU, objGroup, objUser, objFile, objFile2, varDomainNC, objRoot, strText, FirstLine, strFirstName, strLastName, strLine2, objOU2
Set objOU2 = GetObject("LDAP://CN=users,DC=arra,DC=local")
Set objOU = GetObject("LDAP://OU=arra-users,DC=arra,DC=local")
Set objGroup = objOU2.Getobject("group", "cn=CSRs")
strContainer = "ou=Arra-Users"
Set objFSO = CreateObject("Scripting.FileSystemObject")
'***********************************************
'* Connect to a container *
'***********************************************
Set objRootDSE = GetObject("LDAP://rootDSE")
If strContainer = "" Then
Set objContainer = GetObject("LDAP://" & _
objRootDSE.Get("defaultNamingContext"))
Else
Set objContainer = GetObject("LDAP://" & strContainer & "," & _
objRootDSE.Get("defaultNamingContext"))
End If
'***********************************************
'* End connect to a container *
'***********************************************
Set objInFile = objFSO.OpenTextFile("C:\Users\webbc\Desktop\Users.txt", ForReading)
Do until objInFile.AtEndOfStream
strLine2 = objInFile.ReadLine
FirstLine = 0
strText = Replace(strLine2, " ", "§§")
Dim arrText : arrText = Split(strText, "§§")
For Each strLine In arrText
If FirstLine 1 Then
FirstLine = FirstLine + 1
strLine = Replace(strLine, "§§", "")
strFirstName = strLine
Else
strLine = Replace(strLine, "§§", "")
strLastName = strLine
End If
Next
strUser = Left(strFirstName, 1) & strLastName
strDisplayName = strFirstName & " " & strLastName
Set objUser = objContainer.Create("User", "cn =" & strDisplayName)
objUser.Put "displayName", strDisplayName
objUser.Put "description", strLastName & ", " & strFirstName
objUser.Put "sAMAccountName", strUser
objUser.Put "givenName", strFirstName
objUser.Put "sn", strLastName
objUser.Put "userPrincipalName", strUser & "@arra.local"
objUser.Put "Homedrive", "h"
objUser.Put "scriptPath", "login.bat"
objUser.Put "HomeDirectory", "\\indarradc03\Home\" & strUser
objUser.SetInfo
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateFolder("\\indarradc03\Home" & "\" & strUser)
objUser.AccountDisabled = FALSE
objUser.Put "pwdLastSet", 0
'* edit the password to suit
objUser.SetPassword("NewPassword1")
objUser.SetInfo
objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array("cn=" & strDisplayName & ",OU=arra-users,dc=arra,dc=local")
objGroup.SetInfo
Loop
Let me know if you have any questions.
« Windows Updates and Proxy Servers Login Script for Everyone »


what was the format of the text file and was there a delimiter? thanks, this is incredibly helpful!
The file is one name per line.
i.e.:
Christopher Webb
John Doe
Mary Whatever
Also, as an fyi, my blog is moving here. i will try to keep both sites updated for now, but will likely shut this one down soon.
I have had difficulties reading this post using my Iphone, why is that?
I am currently using a theme created by someone else. Someday, when I have some time, I will do a redesign with my own CSS and be sure to make it more readable on mobile devices.
Hi Christopher,
Your script is good and very much usefull.But in which type i should give the text file i didnt understand and also i want to add one more column to the script i.e., to add PS ID too means its an identity number for every user.Request you to help me in this,as your help is very much useful for me as iam doing it dialy manually for a bulk of users.
You can mail me also at bhaska(dot)v25 @ gmail(dot)com
Thanks,
Bhaskar.V