×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

script to clone user accounts in windows 2000

script to clone user accounts in windows 2000

script to clone user accounts in windows 2000

(OP)
Dear All,

Is it possible to write a vbscript to clone user accounts in windows 2000???

If yes .. please reply .

Thanks in Advance

Aslam

RE: script to clone user accounts in windows 2000

The word "close" is a tough one but the answer is Yes.  It is possible to write a script that will extract all user properties and can duplicate thsoe settigns in another domain.

The problem here is that if you will be moving data over, the user's SID will be different and this could give you some troubles with file ownerships.  

You should take a look at ADMT which is a free tool on the Windows 2000/2003 Server CD.  It can do the cloning of user objects for you.

I hope you find this post helpful.  Please let me know if it was.

Regards,

Mark

RE: script to clone user accounts in windows 2000

Sorry I hit submit too soon.  ADMT can do the cloning while PRESERVING SID history.

I hope you find this post helpful.  Please let me know if it was.

Regards,

Mark

RE: script to clone user accounts in windows 2000

(OP)
Maek Thanks for your Input, However want to clone the account to create new user ids in the same domain..

So is it possplie to copy the user accounts usnig the script to create bulk users in AD.


Thanks though !!!

Aslam

RE: script to clone user accounts in windows 2000

I don't understand?  Are you saying you want to create multiple user IDs all with the same information (except for username)?  Or in other words, are you looking ot create a bunch of IDs using another as a template?

I hope you find this post helpful.  Please let me know if it was.

Regards,

Mark

RE: script to clone user accounts in windows 2000

(OP)
Tht's right I m looking to create bunch of user ids using another as a template.

Thanks

Aslam

RE: script to clone user accounts in windows 2000

OK, here you go. This script will make users from an Excel spreadsheet.

You could either copy and paste duplicate information in the spreadhseet or you coud alter the script to use constants.  Either way it is easy to do what you are looking for.  

You will need to alter the LDAP path in this script to match where you want the users created in your AD.  Let me know if you need help identifying that path in your network.

Enjoy.

CODE

'==========================================================================
'
' NAME: createNewUsers.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE  : 04/21/2003
' COPYRIGHT 2003 The Spider's Parlor, All Rights Reserved
'
' COMMENT:
' Creates users based on Excel spreadsheet information.
' Excel spreadsheet  formatting:
' Row 1 to have headings
' Column A (1) to have login
' Column B (2) to have first_name
' Column C (3) to have last_name  
' Column D (4) to have phone      
' Column E (5) to have extension  
' Column F (6) to have fax        
' Column G (7) to have email      
' Column H (8) to have street     
' Column I (9) to have suite     
' Column J (10) to have city  
' Column K (11) to have state      
' Column L (12) to have zip    
'=====================================

set x = getobject(,"excel.application")
r = 2

Const c = "US"
Const co = "UNITED STATES"
'Change the following with your company info
Const company = "Company XYZ"
Const ou_name = "Users"

do until len(x.cells(r, 1).value) = 0

    login      = x.cells(r, 1).value
    first_name = x.cells(r, 2).value
    last_name  = x.cells(r, 3).value
    phone      = x.cells(r, 4).value
    extension  = x.cells(r, 5).value
    fax        = x.cells(r, 6).value
    email      = x.cells(r, 7).value
    street     = x.cells(r, 8).value
    suite      = x.cells(r, 9).value
    city       = x.cells(r, 10).value
    state      = x.cells(r, 11).value
    zip    =cstr(x.cells(r, 12).value)


    
'Change the following with the proper LDAP path for your network.
    set o = getobject("LDAP://SERVER.XYZ.com.local/CN=Users,DC=XYZ,DC=com,DC=local")

    if err then
        x.cells(r, 15).value = err.number & ":  " & err.description
        err.Clear
    end if
    

   Set oUser = o.Create("user","CN=" & Cells(r,1).Value)
   For j = 2 To Columns.Count

    if len(Cells(r,j).Value) = 0 then
       Cells(r,j).Value = " "
    end If

    if fn + ln = 0 then
       fullName = x.cells(r, 1).value
    else
       fullName = first_name & " " & last_name
    end if



     oUser.Put Cells(1,j).Value, Cells(r,j).Value
     oUser.SetInfo
   Set oUser = Nothing
   Next

  
  
            
    
    


    
    Set oUser = o.Create("user","CN=" & fullName)
    oUser.Put "sAMAccountName", login
    oUser.SetInfo
    oUser.Put "userPrincipalName", email
    oUser.SetInfo
    oUser.Put "c", c
    oUser.Put "co", co
    oUser.Put "company", company
    oUser.Put "displayName", first_name & " " & last_name
    oUser.Put "facsimileTelephoneNumber", fax
    oUser.Put "givenName", first_name
    oUser.SetInfo
    oUser.Put "l", "Phoenix"
    oUser.Put "mail", email
    oUser.Put "mailNickname", login
    'oUser.Put "name", first_name & " " & last_name
    oUser.Put "otherTelephone", "Ext. "& extension
    oUser.Put "postalCode", zip
    oUser.SetInfo
    oUser.Put "sn", last_name
    oUser.Put "st", state
    oUser.Put "streetAddress", street & vbCrLf & Suite
    oUser.Put "telephoneNumber", phone & "Ext. "& extension
    oUser.SetPassword login
    oUser.SetInfo
    oUser.AccountDisabled = False
    oUser.SetInfo
    

    If Err.Number <> 0 And Err.Number <> -2147019886 Then
        x.cells(r, 15).value = err.number & ":  " & "ID creation error"
    Else

    x.cells(r, 15).value = "created"
        end if


    r = r + 1
    

    set objOU = Nothing
    set oUser = Nothing    
    set o = nothing
Err.Clear
Loop


set x = nothing

msgbox "done"

I hope you find this post helpful.  Please let me know if it was.

Regards,

Mark

RE: script to clone user accounts in windows 2000

(OP)
Hi,

The script can create users, tht's fine.. How do I add tem into the security gropus.. & anothe rproblem is I need to set my diskquota grp as a Primary gropu.

Thanks though .....

Aslam

RE: script to clone user accounts in windows 2000

Adding users to groups is fairly simple.

the code below assumes you have already defined the username as objUser.

CODE

'define the path to the group
gpstr = "LDAP://SERVER.XYZ.com.local/CN=GroupName,CN=Users,DC=XYZ,DC=com,DC=local"
'bind to the group
set objGroup = GetObject(gpstr)
'now add the user to the group
objGroup.Add objUser.ADsPath

Sorry I can't help you with the disk quotas.  I would recommend posting that as a seperate question.

I hope you find this post helpful.  Please let me know if it was.

Regards,

Mark

RE: script to clone user accounts in windows 2000

(OP)
Thanks,,,


But how abt adding the 100 users to 3 security groups simulteniously.. & set one of them as primart group.


Regards,

Aslam

RE: script to clone user accounts in windows 2000

The overhead on that would be a bit much.  You would be better running the group add script on its own.  You could use an array to loop through the three security groups.

Generally speaking you don't want to change the default group from Domain users.

I hope you find this post helpful.  Please let me know if it was.

Regards,

Mark

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close