Active Directory – Add Computers and Users via Command Line

So you want to add Oranizational Units, Computers and Users to an Active Directory by using command lines. Why would you want to do this when there is a nice graphical interface? One reason would be when you have several computers or users to add; the graphical interface is nice but slow when there are several items to add. Another reason would be when there is no grahical interface to use, for example, only a core operating system is installed.

For example:
We want to create several computers and users at various OU levels, like this…

Here are the commands to add these items:

    dsadd ou ou=Topou,dc=domain,dc=com
    dsadd ou ou=Subou,ou=Topou,dc=domain,dc=com
    dsadd computer cn=Computer01,dc=domain,dc=com
    dsadd computer cn=Computer02,ou=Topou,dc=domain,dc=com
    dsadd computer cn=Computer03,ou=Subou,ou=Topou,dc=domain,dc=com
    dsadd user cn=User01,dc=domain,dc=com
    dsadd user cn=User02,ou=Topou,dc=domain,dc=com
    dsadd user cn=User03,ou=Subou,ou=Topou,dc=domain,dc=com

domain is the second level of the domain
com is the top level of  the domain name

Note that these are the simplified versions of the commands.  When adding users you would normally specifiy other parameters like not disabling the account (the default is to create a disabled account), setting a password, etc.

-disabled no -pwd usersPassword&  -pwdneverexpires yes -canchpwd no

Have fun.