Effective ways to create multiple users at once.

Posted on 2008-10-23
Last Modified: 2012-06-21
What are the most effetive ways people use to create multiple user accounts at once?  Ive read about programs or scripts that read off of a text or excel file, but I'm not really sure where to start.  Is a script the best place to start, or are there better utilites to use?  All help would be appreciated.
Question by:Go-GBS
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 18

Accepted Solution

exx1976 earned 250 total points
ID: 22790052
I use VBS to batch create accounts from an Excel file.  I work for a call center company, so turnover is quite high.  There are ~15 new employees every Monday.

Plus, by creating the accounts with a script, they are all uniform.  No mispellings in address or phone number, never "forget" to add them to a security group, etc etc.  They are always set up exactly the same.

Author Comment

ID: 22790085
Where could I look for a script like this.

Expert Comment

ID: 22790159
try to search at Technet script center

but why VBS -> there is better scripting posibility from MS -> powershell...
LVL 18

Expert Comment

ID: 22790260
User Creation scripts are VERY customized for the environment in which they are used..  Username naming conventions, addresses, phone numbers, group membership, OU's, etc etc..

I can help you out with the basic mechanics, but you're going to need to either learn a little VBS, or reveal a LOT of specifics about your AD...

Here's a generic one.  I think I scrubbed out everything from my domain.  I can't guarantee it'll work, as it was a quick scrub job (besides, you need to enter the info for your domain), but this is a good starting point.  It expects an excel spreadsheet names users.xls in the same directory as the script.  The first row should be a header record (the script skips it), column A should be last name, column b first name, and column c employee ID number.  This script creates accounts as firstname.lastname for the login name, and the default password is "Password".  Further, it sets the login hours by copying them from a user named jdoe in the MyUsers OU.

After it runs, it scrubs the spreadsheet so it can be used again.

There's also a bunch of stuff in here for configuring Terminal Server settings (we use Citrix).

There should be sufficient notes in there to allow you to figure most of it out.

sPath = WScript.ScriptFullName
'WScript.Echo sPath
sPath = Left(sPath,Len(sPath)-Len(WScript.ScriptName))
Set oFS = CreateObject("Scripting.FileSystemObject")
' create Excel
Set oExcelApp = CreateObject("Excel.Application")
' get the Users.xls file and set a reference to the workbook
Set oWorkbook = oExcelApp.Workbooks.Open(sPath & "users.xls")
' get a reference to the 1st worksheet and activate it
Set oWorksheet = oWorkbook.Worksheets(1)
' make Excel invisible
oExcelApp.Visible = False
Dim ArrVals(2)
bEmpty = False
iCounter = 2
Do Until bEmpty = True
	EmptyCounter = 0
	For q = 0 To 2  'skips incomplete records
		ArrVals(q) = ""
		ArrVals(q) = oWorksheet.Cells(iCounter, q + 1)
		If ArrVals(q) = "" Then EmptyCounter = EmptyCounter + 1
	If EmptyCounter = 0 Then
    ' add a user passing down the values from the cells
    	AddUser ArrVals(0), ArrVals(1), ArrVals(2)
    	iCounter = iCounter + 1
    End If
    If EmptyCounter = 3 Then bEmpty = True
If iCounter = 2 Then 
End If
bEmpty = False
iCounter = 2
Do Until bEmpty = True
	strUser = oWorksheet.Cells(iCounter, 1)
	if strUser = "" Then
		bEmpty = True
		oWorksheet.Cells(iCounter, 1).Value = ""
		oWorksheet.Cells(iCounter, 2).Value = ""
		oWorksheet.Cells(iCounter, 3).Value = ""
		iCounter = iCounter + 1
	End If
Sub AddUser(byVal sLastName, byVal sFirstName, ByVal sID)
	ReportedFullName = sFirstName & " " & sLastName
	sLastName = strip(sLastName)
	sFirstName = strip(sFirstName)
	sFirstName = UCase(Left(sFirstName,1)) & LCase(Right(sFirstName, Len(sFirstName)-1))
	sLastName = UCase(Left(sLastName,1)) & LCase(Right(sLastName, Len(sLastName)-1))
	Set oOU = GetObject("LDAP://OU=MyUsers,DC=MyDomain,DC=local")
	sUserName = sFirstname & "." & sLastName
	' create user
	Set oUSR = oOU.Create("user", "CN=" & sUserName)
	'set the properties of the new user
	oUSR.Put "samAccountName", cstr(sUserName)
	oUSR.Put "givenname", cstr(sFirstName)
	oUSR.Put "sn", cstr(sLastName)
	oUSR.put "displayName", CStr(sFullName)
	oUSR.put "co","country"
	oUSR.put "countryCode",840
	oUSR.put "l","city"
	oUSR.put "physicalDeliveryOfficeName","city"
	oUSR.put "postalCode","zipcode"
	oUSR.put "st","state"
	oUSR.put "streetAddress","title"
	oUSR.put "title","title"
	oUSR.put "userPrincipalName",sUserName & "@MyDomain.local"
	oUSR.put "company", "companyname"
	oUSR.put "department", "blahblah"
	oUSR.put "description", "title"
	oUSR.put "division" , "city"
	oUSR.put "telephoneNumber" , "212-555-1212"
	oUSR.put "employeeID" , CStr(sID)
	'msgbox sUserName & " created successfully"
	'Set user default password
	oUSR.SetPassword "Password"
	'force user to change password at first login
	oUSR.Put "pwdLastSet", CLng(0)
	'unlock account (accounts are created disabled by default)
	oUSR.AccountDisabled = False
	oUsr.AllowLogon = 0   							' Disabled = 0, Enabled = 1
	oUsr.EnableRemoteControl = 0					' EnableRemoteControl Values:
   	                                    			' Disable               = 0
   	                                    			' EnableInputNotify     = 1
   	                                    			' EnableInputNoNotify   = 2
   	                                    			' EnableNoInputNotify   = 3
   	                                    			' EnableNoInputNoNotify = 4
	oUsr.BrokenConnectionAction = 0      			' Disconnect = 0, End Session = 1
	oUsr.MaxConnectionTime = 0		  		 		' Time in minutes
	oUsr.MaxDisconnectionTime = 0			    	' Time in minutes
	oUsr.MaxIdleTime = 0 					    	' Time in minutes
	oUsr.ReconnectionAction = 0 		     		' Any Client = 0, Originating client = 1
	oUsr.ConnectClientDrivesAtLogon = 0		  		' Disabled = 0, Enabled = 1
	oUsr.ConnectClientPrintersAtLogon = 0 		   	' Disabled = 0, Enabled = 1
	oUsr.DefaultToMainPrinter = 1					' Disabled = 0, Enabled = 1
	oUsr.TerminalServicesInitialProgram = ""
	oUsr.TerminalServicesWorkDirectory  = ""
	oUsr.TerminalServicesProfilePath = "C:\profile\user"
	'the next three lines get the logon hours from the user jdoe and apply it to the new user
	Set oUser = GetObject ("LDAP://CN=jdoe,OU=MyUsers,DC=MyDomain,DC=local")
	hours = oUser.LogonHours
	oUSR.put "LogonHours",hours
End Sub
function strip(text)
	text = Trim(text)
	index = Len(text)
	For i = 1 To index
		temp = Left(text,i)
		If right(temp,1) = "." Or right(temp,1) = " " Or right(temp,1) = "-" or right(temp,1) = "'" Then
			If i = 1 Then temp = Right(text,Len(text)-i)
			If i > 1 Then temp = Left(text,i-1) & Right(text,Len(text)-i)
			text = temp
			index = Len(text)
			if i > 2 Then i=i-2
		End If
	strip = text
End Function

Open in new window

LVL 18

Assisted Solution

BSonPosh earned 250 total points
ID: 22791317

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

707 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