Method 2: By using the DSADD USER command:
dsadd user "cn=Test User,ou=Test OU,dc=india,dc=net" -samid
testuser -upn testuser@india.net -fn Test -ln User -display
"Test User" -pwd P@ssw0rd -disabled no
This will create one user called "Test User" with all the necessary information (and as I said earlier, more attributes can be easily configured in the same way).Lamer Note: Note that you want to use the same syntax as above, you must first create the "Test OU" OU in you AD, and also change the DN of the domain to the name of YOUR domain.
However we would like to create many users for testing purposes. Therefore we can use the FOR command like we did before:
FOR /L %i in (1,1,500) DO dsadd user "cn=Test User%i,ou=Test
OU,dc=india,dc=net" -samid testuser%i -upn testuser%i@india.net
-fn Test -ln User%i -display "Test User%i" -pwd P@ssw0rd -disabled no
This script will create 500 users called Test User1, Test User2 and so on.Like with NET USER, the DSADD USER command can be used along with a text or CSV file that contains a list of all the users that you want to build.
Create a text file like this one:
Blue,Kelly,bluek,04-6545645
Ben-Sachar,Ido,bensachari,03-7634545
Fluegel,Jay,fluegelj,03-9875765
Grande,Jon,grandej,02-6674534
Hankin,Alex,hankina,04-8856476
Name the file USERS.TXT and place it in a directory.
Now open a CMD in that directory and run the following command:
for /F "eol=; tokens=1,2,* delims=," %%i in (users.txt) do
dsadd user "cn=%%j %%i,ou=Test OU,dc=india,dc=net" -samid
%%k -upn %%k@india.net -fn %%j -ln %%i -display "%%j %%i"
-pwd P@ssw0rd -disabled yes
This will create user accounts with the names found in the USERS.TXT file.
Imagine the power of such a script!
No comments:
Post a Comment