No announcement yet.

How can I create users by scripts

  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I create users by scripts

    First , I would like to introduce about me please . I'm an IT who have been living in HCM city when I was child and now I have been working for TTTCorporation since many years ago
    This is a first time that I take part to this forum also I hope will be learn many experiences from the other members on this forum . Now I have a problem that want the members help me about scripts . Example I have 500 users and now I want to write a script that when I run it , it will create 500 users for me automate I have been trying with other tools such as CSVDE,LIDF , but they are very difficult for me because when I was using that ways I must created a list users already , Could you help me create my users by other way ?

  • #2
    Re: How can I create users by scripts

    Hi ThanhDuongCong, Welcome!

    For an automated creation of 500 new userobjects in Active Directory, you must provide them unique names. If you do not have a list of accountnames, then use the numbers between 100 and 500 to name the users.

    Using the Search button I searched for: Bulk User Creation
    And found a script via this link;

    '// Bulk user creation script
    '// originally posted;
    strUPNSuffix = ""
    strDefaultPassword = "Wind0ws2003"
    strCreateOU = "ou=MailRelay"
    Set oRoot = GetObject("LDAP://rootDSE")
    Set oDomain = GetObject("LDAP://" & oRoot.Get("defaultNamingContext"))
    Set oOU = oDomain.Create("organizationalUnit", strCreateOU)
    oOU.Put "Description", "OU for bulk creation test users"
    For i=100 to 500
    	Set oUser = oOU.Create("User", "CN=User" & i)
    	oUser.Put "sAMAccountName", "User" & i
    	oUser.Put "userprincipalname", "User" & i & strUPNSuffix
    	oUser.Put "DisplayName", "User" & i
    	oUser.Put "sn", "Relay_" & i
    	oUser.Put "givenName", "Mail"
    	oUser.Put "mail", "MailRelay_" & i & strUPNSuffix
    	oUser.Put "Description", "Mail relay test user #" & i
    	oUser.SetPassword strDefaultPassword
    	oUser.AccountDisabled = False

    This posting is provided "AS IS" with no warranties, and confers no rights.


    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts