The company now needs to build a domain environment, as a network management has come a live ah. Adding users one by one this is a very unwise choice ah, the user basically has some common attributes, batch processing is more convenient.
Basic Environment: Windows Server 2003 Simplified Chinese + SP2 domain name: milipp.com
Easy to handle with a for statement
We need to create two file for statement files and user files (note: Two files need to be stored in the same place), for statement file we named Add.bat user file we named User.txt
In the Add,bat file I first write the approximate atch code, and then one by one explain.
for/f "token=1,2"%%a in (user.tatchxt) do dsadd user cn=%%a,ou=test,dc=milipp,dc=com-upn%%a@milipp.com-disp Lay%%b-pwd pengfei_001-pwdneverexpires yes-disabled no--acctexpiress never
All right, there are so many things in the change file, is it very simple. The next time our user files User.txt
Basic format is User login name user reality name such as: Test1 Test 1 (Must have spaces in the middle)
It's time to double Add.bat
As shown in figure this is the result of the creation:
User login name, Password never expires, the account is not used in the period, basically the same as the settings in the file!
We still need to be aware that our passwords are compliant with password complexity, and we can use the Pause keyword after the For statement to see if our command was executed successfully. Look at the contents of this hint!