I have been trying since this morning to add 100 users to a new AD on Server 2008.
The fields I have in a excel file are :
Surname, Forename, username, password, group (NewUser, PowerUser, SuperUser), email addresses (Not exchange just for info sake in the user details).
Following is the script, I copied from a website on someone's advise :
Script code :
---[AddUser.cmd]---- @echo off setlocal :: *** csv-File with the name, first name, and user name: set UserFile=C:\Users\Administrator\Desktop\scriptusers\users1.csv :: *** Distinguished Name of the container to add the new user to: set UsersDN=OU=newcompany,DC=domain,DC=com for /f "tokens=1-4 delims=," %%a in ('type "%UserFile%"') do ( set LastName=%%a set FirstName=%%b set NewUser=%%c set Password=%%d call :process ) goto :leave :process set UPN=%NewUser%@%UserDNSDomain% set DisplayName=%LastName%, %FirstName% set NewUserDN=CN=%NewUser%,%UsersDN% set Password=password echo You are about to create a new user with the following properties: echo. echo Username: %NewUser% echo Display name: %DisplayName% echo UPN: %UPN% echo OU: %UsersDN% echo. echo Hit ^<ctrl-c^> to stop, any other key to create the user. pause >NUL echo. :: *** Test mode: Remove the "ECHO" in front of the following line to run the script for real: dsadd user "%NewUserDN%" -samid %NewUser% -upn %UPN% -fn "%FirstName%" -ln "%LastName%" -display "%DisplayName%" -pwd "%Password%" -desc "%DisplayName%" -mustchpwd yes -disabled no :leave
Now, I exported the excel file to csv, edited the script to my liking, but when I run it, it only adds ONE user (the first one on the csv) or it will give error on password complexity. I changed the password in the script to be complex enough but no luck.
I will be really grateful if someone could let me know how to do this step by step ; I am a novice in scripting and or understanding scripts.
Thanks and Regards AerAps