批量添加域账户 2种方法

来源:互联网 发布:linux tomcat安装配置 编辑:程序博客网 时间:2024/06/06 09:00

批量添加域账户 方法1

======================================================


For /F "tokens=1,2" %%a in (UserList.txt) do dsadd user CN=%%a,OU=test,DC=altn,DC=Com -upn %%a@altn.com -display %%b -pwd p@ssw0rd -pwdneverexpires yes
======================================================
---------------------------------------------------------
dsadd user "CN=zwx167215,CN=Users,OU=myusers,DC=zhoujie-c54800c,DC=china,DC=local" -display "zhou jie" -pwd p@ssw0rd001 -mustchpwd yes
---------------------------------------------------------

UserList.txt (拼音和中文名之间有一个空格)
======================================================

zhangsan 张三
lisi 李四
wangwu 王五
======================================================


如果是xxx.a.com.cn.local这种情况的话,OU=MyNames,OU=Users,OU后面要写成,dc=a,dc=com,dc=cn,dc=local ! 其实把它看成一个路径就行,告诉DSADD命令在哪个路径下添加新的域用户,可以打开adsiedit.msc来查看你现有用户,参考进行添写!


批量添加域账户 方法2

http://support.microsoft.com/kb/199878/en-us

AddUsers Automates Creation of a Large Number of Users

System TipThis article applies to a different version of Windows than the one you are using. Content in this article may not be relevant to you. Visit the Windows XP Solution Center
This article was previously published under Q199878
Expand all |Collapse all

SUMMARY

The Addusers.exe tool for Windows is a 32-bit administrative utility that uses a comma-delimited text file to create, modify, and delete user accounts. Addusers is most beneficial when the information to be manipulated is maintained in a spreadsheet, such as one created with Microsoft Excel, that can be converted to a comma-delimited file. You must be a member of the Administrators group on the target computer to add accounts and a member of the Users group to write to accounts.
Back to the top |Give Feedback

MORE INFORMATION

The AddUsers command uses the following syntax:

AddUsers {/c|/d{:u}|/e} filename [/s:x] [/?] [\\computername|domainname] [/p:{l|c|e|d}]
  • \\computername - is the computer where you want to create user accounts or from which you want to write user accounts. If you do not specifycomputername, AddUsers uses the local computer by default.
  • domainname - This option can be used in place of computername. If this option is used, then Addusers queries the PDC of the domain specified.
  • /c - Creates user accounts, local groups, and global groups as specified by filename.
  • /d{:u} - Dumps user accounts, local groups, and global groups to the specified file name. The (:u) is an optional switch that causes current accounts to be written to the specified file in Unicode text format. Choosing to dump current user accounts does not save the account's passwords or any security information for the accounts. To back up security information for accounts, a Tape Backup should be used.
    Note: Password information is not saved in a user account dump and if you use the same file to create accounts, all passwords of newly created accounts will be empty. All created users are required to change their password at logon by default.
  • /e - Erases the user accounts specified in the file name.
    CAUTION: Be careful when erasing user accounts, as it is not possible to recreate the user account with the same SID. This option, however, cannot erase built-in accounts.
  • Filename - The comma-delimited input/output file that AddUsers uses for data.
  • /s:x - This a optional switch that changes the character used for separating fields in the file. Thex should be replaced with the new character to be used for separating fields. For example,/s:~ would make the field-separation character the "~" (tilde). If this option is not specified, the default separator, a comma, is used.
  • /? - Displays a help screen.
  • If you are using Windows NT 4.0, the newer version of Addusers.exe is available in the Windows NT Resource Kit, Supplement 3, has added a /p switch. This switch increases functionality when creating new users with AddUsers.exe in Windows NT.
  • /p: - Sets account creation options. It can be used along with any combination of the following options:

    • l - Users do not have to change passwords at next logon.
    • c - Users cannot change passwords.
    • e - Passwords never expire. (implies l option)
    • d - Accounts disabled.

    Sample: Creating New Users and Groups with Addusers

    1. Log on as a user who is a member of the Administrators group of the target computer.
    2. Create a comma-delimited text file, which contains the new users and groups to be created. Syntax is section-specific for each entry (line) in the different sections, as follows:

      [Users]
      User Name,Full name, Password, Description, HomeDrive, Homepath, Profile, Script

      [Global]
      Global Group Name, Comment, UserName, ...

      [Local]
      Local Group Name, Comment>, UserName, ...

      The entries (lines) in the [Local] and [Global] group sections can have 0 or moreUserName entries after the comment field. Each user name is added to that group. Lines must end with a comma (or the appropriate separator character). Here is the example from the Resource Kit Tools Help file for AddUsers.exe:

      [User]
      jimmy,James Edward Phillip II,,,,,,
      alex,Alex Denuur,,,E:\,E:\users\alex,,
      ron,Ron Jarook,hello,,E:\,E:\users\ron,,
      sarah,Sarah Selly,,,,,,
      mike,Mike Olarte,,,,,,

      [Global]
      TestTeam,Regression,ron,alex,
      DevTeam,Conversion to Sources,mike,sarah,jimmy,

      [Local]
      UsersAM,Users A through M,alex,jimmy,mike,
      UsersNZ,Users N through Z,ron,sarah,
    3. Save the file.
    4. Creating the users (and groups) can be performed through a batch file or at the command line. The following command creates the users and groupslisted in a text file called Users.txt. The "/p" switch creates the userswith the Passwords Never Expire option enabled:

      C:\>AddUsers [\\computername] /c c:\Users.txt /p:e

      Alternatively, using a domain name, the syntax would be:

      C:\>AddUsers [domainname] /c c:\Users.txt /p:e

    Sample: Generating a List of User Accounts and Groups from a Computer Running Windows

    1. Log on as a user who is a member of the Administrators group of the target computer.
    2. At a command prompt, type Addusers \\servername /dfilename.txt (where servername is the name of a domain controller, member server, or workstation), and then press Enter.
    With appropriate permissions, administrators can generate a list of users from domains other than their own. The list is generated into thefilename.txt text file. This file also contains information such as the profile, home directory, and scripts for each user.The NET USERS command also permits modification, deletion, and creation of accounts, but lacks some of the features of Addusers.exe.

    For additional information about creating batch files to automate the creation of users, please see the following article in the Microsoft Knowledge Base:
    180546 Automating Updates to Local Groups on Member Servers


2、执行命令
参数解释:
计算机名:要建立帐号的计算机名
/c:使用文件引入用户列表
file path:加/c参数后,指定文件路径
/p:l/c/e/d:帐号选项,其中:
l:使用者下次登录时需更改密码
c:使用者不得变更密码
e:密码永远有效
d:帐号暂停使用


原创粉丝点击