Add User and Computer Objects Script

Does anyone have a good script to create user and computer accounts on a Windows 2003 AD domain? I used to have one but cannot seem to find it.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Krzysztof PytkoConnect With a Mentor Senior Active Directory EngineerCommented:
I would suggest to use dsadd command on server or workstation with Administrative Tools installed

create a bat or cmd file for each department and place there

@echo off

dsadd user "cn=%1,ou=<location_of_userr_OU>,dc=<your_domain>" -samid %1 -upn %1@<fqdn> -fn %2 -ln %3 -display "%2 %3" -pwd Password -desc <description> -memberof "CN=<group_name>,OU=<OU_group_location>,DC=<domain>" -hmdrv <drive:> -hmdir <home_directory_%1> -loscr <logon_script> -mustchpwd yes -canchpwd yes -disabled no

Then run script with 3 parameters 1- login, 2-First Name, 3- Last Name

if you need more assistance, just let me know
elbereth21Connect With a Mentor Commented:
It's been a long while since the last time I used it, but I used to like this one:
Anyway, use it carefully, since today I cannot test it myself.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Krzysztof PytkoSenior Active Directory EngineerCommented:
oh, I missed part of adding computer :)
You can do that using

dsadd computer "cn=%1,ou=<location_for_computer>,dc=<domain>"
MalajloConnect With a Mentor Commented:

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""

    Set objOU = GetObject("ou=a, dc=your_domain, dc=inet ,")

    Set objUser = objOU.Create _
        ("User", "cn=" & objExcel.Cells(intRow, 1).Value)
    objUser.sAMAccountName = objExcel.Cells(intRow, 2).Value
    objUser.GivenName = objExcel.Cells(intRow, 3).Value
    objUser.SN = objExcel.Cells(intRow, 4).Value
    objUser.AccountDisabled = FALSE
    intRow = intRow + 1

Excel structure:
CN (description)      Username      Firstname      Lastname      password
Demo User            UserU      Demo      User      password123

I Agree with iSiek using TXT file to create a script then save it as .bat file
you must create you own script because os OUs name , Domain Name , Password...etc
Da_PirateConnect With a Mentor Commented:
or just use Templates for creating users if they are too many
Ben Personick (Previously QCubed)Connect With a Mentor Lead Network EngineerCommented:
I just finished a script to add users from a CSV File, of course the engineer who built the CSV file did it all wonky, and instead of fixing the CSV file I fixed the values in the batch file, If this ticket is still open when I look back I'll post that code and the format for the CSV.

BoxunloXAuthor Commented:
Thanks guys! I have been so busy I have not gotten to try these scripts yet. I will make it a point to get them tested this week and let you guys know the results.
BoxunloXAuthor Commented:
All great solutions that will work for the problem I was encountering.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.