how to write script for creating users automatically(altogether) in windows 2000 server domain?

Posted on 2006-04-23
Last Modified: 2012-08-13
We rebuilt our PDC...Now we want to create all users through script...

how to write script for creating user in windows 2000 server domain?
What is the syntax?

For eg: User name is "Joji Joseph" and logon ID should be "joji" in group IT

Awaiting ur quick reply...

Question by:JojiJoseph_1975

    Accepted Solution

    Hello Bro
    Let me know if this works for u .....................

    ' Taken from ADS_USER_FLAG_ENUM

    set objParent = GetObject("LDAP://<ParentDN>")
    set objUser   = objParent.Create("user", "cn=<UserName>") ' e.g. joes
    objUser.Put "sAMAccountName", "<UserName>"   ' e.g. joes
    objUser.Put "userPrincipalName", "<UserUPN>" ' e.g.
    objUser.Put "givenName", "<UserFirstName>"   ' e.g. Joe
    objUser.Put "sn", "<UserLastName>"           ' e.g. Smith
    objUser.Put "displayName", "<UserFirstName> <UserLastName>" ' e.g. Joe Smith

    ' CORRECTION: If you don't set userAccountControl, then by default
    '             the value of 514 (normal account + disabled) will be set for it.
    '             In this instance by setting it to 512, the account will not
    '             be disabled, and if you have password complexity enabled in
    '             your forest, the script will fail because a password was not
    '             set prior to the account being enabled.  The solution is to
    '             not set userAccountControl here.
    ' objUser.Put "userAccountControl", ADS_UF_NORMAL_ACCOUNT

    objUser.AccountDisabled = FALSE

    Enjoy ..........
    LVL 10

    Assisted Solution

    Are you trying to automate adding a bunch of users at one time?  This will do one at a time ...

    For a batch file, you could use the "net user" and "net group" commands to accomplish your task.  For example, if you want to use it to set up the 3 fields you entered above (with an initial default password of "password"), you could save the following as "userscript.bat":

    @echo off
    net user %2 password /add /fullname:%1
    net group IT %2 /add

    Then just run it like:
    userscript "Joji Joseph" joji IT
    LVL 6

    Expert Comment

    LVL 6

    Expert Comment

    If you dont have "Resource Kit for Windows 2000 " you can download Add Users from here.
    LVL 6

    Expert Comment

    Sorry for the wrong writing in last post.

    If you don’t find your "Resource Kit for Windows 2000" you can download Add Users from here.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Occasionally Windows/Microsoft Updates will fail to update. We have found a code that will delete all temporary files and re-register all dll's related to Windows/Microsoft Updates! This works 99% of the time to get the updates working again! The…
    Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    779 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

    9 Experts available now in Live!

    Get 1:1 Help Now