Set user password with vbs, where value is taken from an xls document
Hello Technet,
Im trying to set a random password for users I have to create, but I don't know the value or if it's even possible. What I have so far, which works fine is:
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
("C:\04.w.f1.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
Set objOU = GetObject("LDAP://OU=Users,OU=Users and Groups,OU=04-West-F1,DC=f1,DC=lcl")
Set objUser = objOU.Create _
("User", "cn=" & objExcel.Cells(intRow, 1).Value)
objUser.sAMAccountName = objExcel.Cells(intRow, 2).Value
objUser.GivenName = objExcel.Cells(intRow, 3).Value
objUser.SN = objExcel.Cells(intRow, 4).Value
objUser.userPrincipalName = objExcel.Cells(intRow, 5).Value
objUser.SetInfo
intRow = intRow + 1
Loop
objExcel.Quit
Is there a parameter for setting password also. It has to take the value from the same xlx document, etc in row 6.
Best Regards
Jesper Vindum, Denmark
August 11th, 2012 11:11am
Hi Jesper,
Please seek help in The Official Scripting Guys Forum!
http://social.technet.microsoft.com/Forums/en/ITCG/threadsThanks !
Free Windows Admin Tool Kit Click here and download it now
August 11th, 2012 12:37pm
Jesper,
Just add the line objUser.setpassword "12345678" or whatever.
August 12th, 2012 10:27am
I know, but it has to be custom for all users. But I when to the scripting forum, as suggested. There is the answer.
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/9e2e6ba7-3f63-48a4-8fc7-0023932ef414/#9e2e6ba7-3f63-48a4-8fc7-0023932ef414
Free Windows Admin Tool Kit Click here and download it now
August 12th, 2012 12:38pm