There are several main ways to create users in AD:
1) AD Users and Computers | AD Admin Center
2) Create users in bulk using CSVDE
3) Create users in bulk using LDIFDE
4) batch create user with PowerShell script
5) Batch create users with the For statement combined with the dsadd command
Analysis:
The 1th kind is GUI interface, at a glance, need not say more;
2nd, 3 types can not enter the password for the user, so after the completion of the disabled state;
The 4th kind of function is very powerful, but has certain threshold, later for everybody to share;
Today we introduce the 5th type, reason: simple and practical!
Main steps:
1, first use Notepad or Excel to make a template file, save in TXT or CSV format
2, and then use the for command combined with dsadd to complete the batch creation of users
Command format
for/f "tokens=1,2,3,4,5 delims=,"%a in (c:\sr_users.txt) do dsadd user "cn=%c,ou=sales,dc=sr,dc=com"-samid%d-upn%[ Email protected]-ln%A-FN%b-pwd%e-disabled No
Command explanation:
tokens=1,2,3,4,5: Indicates that there are five variables (parameters are 5 parameters in the table, in order of a/b/c/d/e)
Delims=,: Indicates that the delimiter is ","
%a in (\ Sr_users.txt): Indicates that the variable takes data from the path "C:\sr_users.txt"
dsadd: Create user command
Cn=%c,ou=sales,dc=sr,dc=com: Indicates the user name created and where it was created
-samid%D-UPN%d: Indicates that the login name is variable D
-LN%a: Set user name to variable a
-FN%b: Set user name to variable b
-pwd%e: Set Password to variable E
-disabled No: Indicates that the import is enabled later.
Below we kind a sprinkle
Requirement: Create 4 users in bulk under the organizational unit Sales (created) in the domain sr.com (for example, ha, meaning)
User template files and for statements
650) this.width=650; "title=" clip_image002 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px, "border=" 0 "alt=" clip_ image002 "src=" http://s3.51cto.com/wyfs02/M02/6F/F6/wKiom1WuHgjTdU78AAJBQsquu0w710.jpg "height=" 403 "/>
The For statement executed successfully
650) this.width=650; "title=" clip_image004 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px, "border=" 0 "alt=" clip_ image004 "src=" http://s3.51cto.com/wyfs02/M00/6F/F6/wKiom1WuHgmRzBj_AAEZQoE0oB4525.jpg "height=" 390 "/>
Verify that it is already in the ad user and computer.
If you create a very large number of users, it is recommended that you put it in an Excel file, which makes it easier to view and edit.
For statement implementation bulk AD user creation