I've got the following script that creates user accounts based on the input of CN/SANAccountName from a XLS file. The file works assuming that the accounts don't exist in the OU specified.
Can someone assist altering so that if the account exists it just resets the password?
SCRIPT:
dim sAMAccountName
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
("C:\xxxx.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
Set objOU = GetObject("LDAP://__location__")
Set objUser = objOU.Create _
("User", "cn=" & objExcel.Cells(intRow, 1).Value)
sAMAccountName = objExcel.Cells(intRow, 2).Value
objUser.sAMAccountName = objExcel.Cells(intRow, 2).Value
strNewUPN = sAMAccountName & "@" & "xxx.xxx"
objUser.userPrincipalName = strNewUPN
objUser.SetInfo
objUser.AccountDisabled = FALSE
objUser.SetInfo
objUser.SetPassword("[insertpassword")
ObjUser.SetInfo
intRow = intRow + 1
Loop
objExcel.Quit
Can someone assist altering so that if the account exists it just resets the password?
SCRIPT:
dim sAMAccountName
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
("C:\xxxx.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
Set objOU = GetObject("LDAP://__location__")
Set objUser = objOU.Create _
("User", "cn=" & objExcel.Cells(intRow, 1).Value)
sAMAccountName = objExcel.Cells(intRow, 2).Value
objUser.sAMAccountName = objExcel.Cells(intRow, 2).Value
strNewUPN = sAMAccountName & "@" & "xxx.xxx"
objUser.userPrincipalName = strNewUPN
objUser.SetInfo
objUser.AccountDisabled = FALSE
objUser.SetInfo
objUser.SetPassword("[insertpassword")
ObjUser.SetInfo
intRow = intRow + 1
Loop
objExcel.Quit