March 28, 2018

How to add user in active directory in windows server 2012 R2

❑ CMD example
❍ Add user : dsadd user "cn=user05,ou=test,dc=company,dc=com" -samid user05 -pwd 1q2w3e4r!.
❍ Add OU : dsadd ou "ou=test1,ou=test,dc=company,dc=com"
❍ Extract users to a file : csvde -d "ou=test,dc=compnay,dc=com" -f "c:\rst.csv"
❍ Add user using a file : csvde -i -f "c:\rst.csv"
* "rst.csv" need to be modified : Remove all column except "dn", "objectClass" and  "sAMAccountName".
* ldif : This command is the same format as the csvde command. If you add an account with the "-i" option, you need to modify a "* .ldif" file in the following format.

dn : Cn=user09, ou=test, dc=company, dc=com
objectClass : user
sAMAccountName : user09

❑ Power shell example
❍ New-ADUser "user06" -SamAccountName user06 -Path "ou=test,dc=company,dc=com" -AccountPassword (ConvertTo-SecureString "1q2w3e4r!." -AsPlainText -force)