I have two VBScripts which will create your users accounts in Active Directory.
The first method is relatively straightforward, the second method is more
useful, but needs a spreadsheet holding the user properties.
The strength of this script is that it will create users in any domain. Its
statements are designed to get you started in your quest to script new user
accounts.
' VBScript to create an OU called BulkGuy
' VBScript then creates 20 Users in OU BulkGuy
' Guy Thomas - January 2004
Dim objRoot, objDomain, objOU, objContainer
Dim strName
Dim intUser
strName ="BulkGuy"
Set objRoot = GetObject("LDAP://rootDSE")
Set objDomain = GetObject("LDAP://" & objRoot.Get("defaultNamingContext"))
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objOU=objDomain.Create("organizationalUnit", "ou=BulkGuy")
objOU.Put "Description", "Guy's Bulk Users OU"
objOU.SetInfo
Set objContainer = GetObject("LDAP://OU=BulkGuy," & _
objRootDSE.Get("defaultNamingContext"))
For account = 1 To 20
Set objLeaf = objContainer.Create("User", "cn=" & strName & account)
objLeaf.Put "sAMAccountName", strName & account
objLeaf.SetInfo
intUser = intUser +1
Next
WScript.Echo intUser & " Users created "
WScript.quit
Learning Points
On line 9, just after the variables are declared, is the statement: strName = "BulkyGuy";
perhaps you
would like to change this string to reflect your name.
The reason the script works in any domain is the command: GetObject("LDAP://rootDSE").
This statement means - use LDAP to get the root domain.
For account = 1 To 20. You could amend this to create more, or less
accounts. Note the 'Next' later in the script which makes the routine loop,
and this what creates multiple users.
Technically, cn and sAMAccountName are the only two mandatory properties
for the user object. With Method 1, it is easier to add more
user properties, such as sn = Last Name.
Guy Recommends: Solarwinds' Free Bulk Import Tool
Import users from a spreadsheet. Just provide a list of the
users with their fields in the
top row, and save as .csv file. Then launch this FREE utility and match
your fields with AD's
attributes, click and import the users. Optionally, you can
provide the name of the OU where the new accounts will be born.
There are also two bonus tools in the free download, and all 3 have been approved by Microsoft:
VBScript method 2 works like mail-merge. An Excel spreadsheet holds the
data, while a VBScript reads the users' properties, and then creates the user object in Active Directory. A bonus of this method is that spreadsheet acts as
a record for who you have added to your domain.
The script needs a 'Loop' to read the properties from each row and so
generate a
succession of new users. I have a section in the ebook explaining Do...
Until Loop routines. See Do...Loop
Until
The crucial feature of the spreadsheet is the first row which holds the LDAP
properties for the users. This similar to creating field names for a
database. A key skill is to deduce the LDAP names which correspond to the
user properties; for example the LDAP name for First Name
is givenName.
Now, I have a brand new ebook which has a great script to create users. What you get in the ebook are step-by-step instructions to customize the
example script to suit your own domain. You also get a excel spreadsheet with
LDAP properties in the first row. The ebook is divided into 10
sections each page explains a feature of the script in detail.
Save
hours of frustration and buy Guy's eBook. The features include:
detailed examples on how to import LDAP properties from a spreadsheet, Do...Loop
Until explained, connect to your domain with RootDSE.
You get a printer friendly version with copy
enabled, and no expiry date.
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems.
Fortunately, Solarwinds
have created the
Free WMI Monitor so that you can actually see and understand these gems of
performance information. Take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.