Solved

Add User and Computer Objects Script

Posted on 2010-09-02
11
867 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
  • 2
  • 2
  • 2
  • +4
11 Comments
 
LVL 39

Accepted Solution

by:
Krzysztof Pytko earned 42 total points
Comment Utility
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
Comment Utility
0
 
LVL 11

Assisted Solution

by:elbereth21
elbereth21 earned 42 total points
Comment Utility
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
 
LVL 39

Expert Comment

by:Krzysztof Pytko
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Expert Comment

by:Da_Pirate
Comment Utility
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
Comment Utility
or just use Templates for creating users if they are too many
0
 
LVL 11

Assisted Solution

by:Ben Personick
Ben Personick earned 41 total points
Comment Utility
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
Comment Utility
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
Comment Utility
All great solutions that will work for the problem I was encountering.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Learn about cloud computing and its benefits for small business owners.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now