Solved

Effective ways to create multiple users at once.

Posted on 2008-10-23
5
678 Views
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.
0
Comment
Question by:Go-GBS
[X]
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
5 Comments
 
LVL 18

Accepted Solution

by:
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.
0
 

Author Comment

by:Go-GBS
ID: 22790085
Where could I look for a script like this.
0
 
LVL 5

Expert Comment

by:gratex_ssd
ID: 22790159
try to search at Technet script center

http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct08/hey1020.mspx

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

Expert Comment

by:exx1976
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.


HTH,
exx
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)
oWorksheet.Activate
' 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
	Next
	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
Loop
If iCounter = 2 Then 
	oWorkbook.Save
	oExcelApp.Quit
	WScript.Quit()
End If
bEmpty = False
iCounter = 2
Do Until bEmpty = True
	strUser = oWorksheet.Cells(iCounter, 1)
	if strUser = "" Then
		bEmpty = True
	Else
		oWorksheet.Cells(iCounter, 1).Value = ""
		oWorksheet.Cells(iCounter, 2).Value = ""
		oWorksheet.Cells(iCounter, 3).Value = ""
		iCounter = iCounter + 1
	End If
Loop
oWorkbook.Save
oExcelApp.Quit
WScript.Quit 
 
 
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)
	oUSR.SetInfo
	'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")
	oUser.GetInfo
	hours = oUser.LogonHours
	oUSR.put "LogonHours",hours
	oUSR.SetInfo
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
	Next
	strip = text
End Function

Open in new window

0
 
LVL 18

Assisted Solution

by:BSonPosh
BSonPosh earned 250 total points
ID: 22791317
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

In-place Upgrading Dirsync to Azure AD Connect
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

739 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