Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to add AD users and custom OU users in batches on Windows Server 2008R2

Shulou Source: shulou.com Published: 2022-06-02 17:30:37 09月22日 Update

First of all, here we need to find HR to get the employee's information table, the more detailed the better.

Note: the password should not be too simple, it must meet the requirements of the complexity of the password, otherwise it will prompt the error message.

Then save the table of the modification number to the root directory of disk C.

Add this information below

For / f "skip=1 eol=; tokens=1-10 delims=,"% an in (c:\ aduserdata.csv)

Do dsadd user cn=%a,cn=users,dc=abc123,dc=com

-display a%-upn% c@abc123.com-samid% c-pwd% d-company% e-dept% f

-title% g-office% h-tel% I-fax% j-mobile% k-mustchpwd yes-disabled yes

Reference:

Close the csv file.

Running CMD as an administrator

Command format and parameters of For do

The FOR command iterates through the dsadd command, and the statement in the body of the for program refers to a to get the first symbol

Quote% b to get the second symbol from% averse% z, if your text

There are five columns in the file with values of 1 to 5, and the variable% an is 1, so push it down, and the command line example is as follows:

For / f "skip=1 eol=; tokens=1-9 delims=,"% an 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% f

-office% g-title% h-email% I-mustchpwd yes-disabled yes

Parameter meaning: skip=1 skips the first line of data eol=; comment line begins with the character ";" tokens=1-9

Extract 1-9 variables at a time delims=, split the symbol as ","

Where a%, a represents the corresponding information of row An in the EXCEL table.

C% represents the corresponding information of row C in the EXCEL table.

....

What is shown below is the added content, and it is found that there are two places where the information has not been added. There is a slight problem here, which may have something to do with the horizontal length setting of EXCEL.

The added user information is shown below

View user specific information

Let's manually add OU, as shown in the following figure:

Use the second EXCEL table to add OU users in the same way as above. The information saved as "whqxhruser.csv" is omitted here, and no information that cannot be displayed is found when you add it here.

Note: when using the above EXCEL information to add, you need to delete all the users that have been added, otherwise you will report that the user information already exists and saved.

Display user information in OU

Display the specific information of the users in OU

At this point, this paper introduces how to add AD users in batches and how to customize OU and add users to the corresponding OU.

Tags: Information user command method symbol face representative parameter variable password time table complexity same one line antecedent content meaning employee complexity Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MariaDB Shulou Tech Info Microsoft Shulou Technology