Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 883
  • Last Modified:

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.
0
BoxunloX
Asked:
BoxunloX
  • 2
  • 2
  • 2
  • +4
6 Solutions
 
Krzysztof PytkoActive 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
0
 
elbereth21Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

dsadd computer "cn=%1,ou=<location_for_computer>,dc=<domain>"
0
 
MalajloCommented:
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
 
Da_PirateCommented:
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
 
Da_PirateCommented:
or just use Templates for creating users if they are too many
0
 
Ben Personick (Previously QCubed)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.

~Q
0
 
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.
0
 
BoxunloXAuthor Commented:
All great solutions that will work for the problem I was encountering.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now