Solved

Add User and Computer Objects Script

Posted on 2010-09-02
11
872 Views
Last Modified: 2012-05-10
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.
0
Comment
Question by:BoxunloX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +4
11 Comments
 
LVL 39

Accepted Solution

by:
Krzysztof Pytko earned 42 total points
ID: 33594144
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
0
 
LVL 4

Assisted Solution

by:goyal_251
goyal_251 earned 42 total points
ID: 33594147
0
 
LVL 11

Assisted Solution

by:elbereth21
elbereth21 earned 42 total points
ID: 33594153
It's been a long while since the last time I used it, but I used to like this one: http://www.tek-tips.com/viewthread.cfm?qid=1185348&page=1
Anyway, use it carefully, since today I cannot test it myself.
0
Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 33594186
oh, I missed part of adding computer :)
You can do that using

dsadd computer "cn=%1,ou=<location_for_computer>,dc=<domain>"
0
 
LVL 4

Assisted Solution

by:Malajlo
Malajlo earned 41 total points
ID: 33594420
AddUsers.vbs

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
    ("C:\users.xls")
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
    objUser.SetInfo
    intRow = intRow + 1
Loop
objExcel.Quit

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


0
 
LVL 5

Expert Comment

by:Da_Pirate
ID: 33594498
I Agree with iSiek using TXT file to create a script then save it as .bat file
and
you must create you own script because os OUs name , Domain Name , Password...etc
0
 
LVL 5

Assisted Solution

by:Da_Pirate
Da_Pirate earned 42 total points
ID: 33594505
or just use Templates for creating users if they are too many
0
 
LVL 13

Assisted Solution

by:Ben Personick (Previously QCubed)
Ben Personick (Previously QCubed) earned 41 total points
ID: 33602195
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.

~Q
0
 
LVL 1

Author Comment

by:BoxunloX
ID: 33731591
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.
0
 
LVL 1

Author Closing Comment

by:BoxunloX
ID: 35335565
All great solutions that will work for the problem I was encountering.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question