How do I import a large number of user accounts? It's one of the things we need to consider after 2008r2 installation.
The method is to organize the user information in the Excel document and then use the command or script to import it into the ad.
Of course, the simpler the better, the less we need to modify.
We first get an Excel form for the employee roster from the personnel department
For us, the important thing is name and work number, Department of these 3. Of course, for AD administrators, the more detailed the user account information, the better.
Now let's edit this information:
First add 2 columns, login name and password
Then save the form as a c:\\aduserdata.csv (on the DC)
Turn the CSV file off
Running CMD as an administrator
command format and parameters for do
The for command loops through the dsadd command, and this for-body statement references%a to get the first symbol.
Quote%b to get a second sign from%a~%z if your text
The 5 columns in the file are 1~5 values, and the variable%a is 1, which is pushed down, and the command line is as follows:
for/f "Skip=1 eol=; Tokens=1-9 delims=, "%a in (c:\ADuserdata.csv)
Do dsadd user cn=%a,cn=users,dc=sample,dc=net
-UPN%b@sample.net-samid%b-pwd%c-fn%e-ln%d-dept
-office%g-title%h-email%i-mustchpwd yes-disabled Yes
Parameter meaning: Skip=1 skips the first row of data eol=; Comment Line start character is ";" Tokens=1-9
Fetch 1-9 variable delims= at a time, the split symbol is ","
The result is an error and the file cannot be found. The reason is that CSV can not be read by command in case of open, turn off and then run the command OK
Open the ADUC and you can see
We open any one of the users and view the properties
Test OK, all created successfully
In fact, people with work experience will find that the above created is a problem
What if you don't divide the OU and then run the GPO?
In general, an OU that creates an organizational structure prior to importing a user.
For example, Shanghai Headquarter and Shanghai subsidiary, the following figure
Suggest OU name in English is better, Chinese sometimes have garbled, edit time is more troublesome.
If you follow the above method, you must make a CSV file for each department employee
Below we first do the head office personnel account, save as C:\\shhqhruser. DS1
Add the appropriate OU selection with the for do command
Test OK,
: Even give me 5K of users will not worry.
DSADD user Syntax
dsadd user UserDN [-samid samname] [-upn UPN] [-FN FirstName] [-mi Initial] [-ln LastName]
[-display DisplayName] [-empid EmployeeID] [-pwd {Password | *}] [-desc Description]
[-memberof Group;.] [-office Office] [-tel PhoneNumber] [-email Email] [-hometel Homephonenumber]
[-pager Pagernumber] [-mobile CellPhoneNumber] [-fax Faxnumber] [-iptel IPPhoneNumber]
[-WEBPG webpage] [-title title] [-dept Department] [-company Company] [-mgr Manager]
[-hmdir HomeDirectory] [-hmdrv DriveLetter:] [-profile ProfilePath] [-loscr ScriptPath]
[-mustchpwd {yes | no}] [-canchpwd {yes | no}] [-reversiblepwd {yes | no}] [-pwdneverexpires {yes | no}]
[-acctexpires Numberofdays] [-disabled {yes | no}] [{-S Server |-D Domain}] [-U UserName]
[-P {Password | *}] [Q] [{-UC |-uco |-uci}]