I have purchased a book titled: "Microsoft Vbscript Step by Step" that has a sample script to import multiple user accounts from a "csv" file. My question is; why does the script create the account, but not populate the account with the other information? For example, the account will get created. But when you go to Active Directory, and right-click the account and view its properties, on the "General" tab, the information there is blank. In the script it has all the information there that should be populated. Why is it not populating? Any help that anyone can give me will be greatly appreciated.
--------------------------
----------
----------
----------
--
Start of script
--------------------------
----------
----------
----------
--
On Error Resume Next
Dim objFSO,objTS
Dim objDom,objUser
Const FORREADING=1
strFile="newusers.csv"
'format of newusers.csv
'givenname,sn,password,tel
ephonenumb
er,upnsuff
ix
'example:
'Jeff,Hicks,P@sswordJH,555
-1234,@jdh
itsolution
s.com
'Don,Jones,$cr1pting@nsw3r
s,555-1234
,@scriptin
ganswers.c
om
Set objFSO=CreateObject("Scrip
ting.FileS
ystemObjec
t")
Set objTS=objFSO.OpenTextFile(
strFile,FO
RREADING)
Set objDom=GetObject("LDAP://O
U=Consulta
nts,DC=Com
pany,DC=pr
i")
'open text file and process user data on each line
Do while objTS.AtEndofStream<>True
rline=objTS.readline
UserArray=Split(rline,",")
strFirst=UserArray(0)
strLast=UserArray(1)
strUser=strFirst & " " & strLast
strLogon=Left(strFirst,1)&
strLast
strUsername=LCASE(Left(str
First,1)&s
trlast)
strPass=UserArray(2)
strPhone=UserArray(3)
strUPN=strUserName & UserArray(4)
'Create user object
Set objUser=objDom.Create ("User","cn="&strUser)
objUser.Put "samAccountName",strUserNa
me
objUser.SetInfo
'Now that user object is created, let's set some properties
objUser.Put "givenname",strFirst
objUser.Put "sn",strLast
objUser.Put "displayname",strFirst & " " & strLast
objUser.Put "UserPrincipalName",strUPN
objUser.Put "AccountDisabled",FALSE
objUser.Put "TelephoneNumber",strPhone
objUser.SetPassword(strPas
s)
objUser.SetInfo
Loop
objTS.Close
WScript.Quit
--------------------------
----------
----------
----------
--
End of script
--------------------------
----------
----------
----------
--