VBscript to create users in active directory using spreadsheet

By hmtmbx ·
I need urgent help to solve my problem.Please help me since my server OS windows 2000 has crashed and it is a tough time to add a list of 200 users.
Hence I have given my script below which gives me error code 8007203A - the server is not operational.

What and how should I proceed further.
This is the script.

' UserSpreadsheet .vbs
' Sample VBScript to create User accounts from a spreadsheet
' Author Guy Thomas
' Version 4.6 - June 2005
' -------------------------------------------'
Option Explicit
Dim objRootLDAP, objContainer, objUser, objShell
Dim objExcel, objSpread, intRow
Dim strUser, strOU, strSheet
Dim strCN, strSam, strFirst, strPWD

' --------------------------------------------'
' Important change OU= and strSheet to reflect your domain
' --------------------------------------------'

strOU = "MTBNET.local/OU=Users ," ' Note the comma
strSheet = "E:\scripts\UserSpread1.xls"

'On Error Resume next

' Bind to Active Directory, Users container.
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://" & strOU & _

' Open the Excel spreadsheet
Set objExcel = CreateObject("Excel.Application")
Set objSpread = objExcel.Workbooks.Open(strSheet)
intRow = 3 'Row 1 often contains headings

' Here is the 'DO...Loop' that cycles through the cells
' Note intRow, x must correspond to the column in strSheet
Do Until objExcel.Cells(intRow,1).Value = ""
strSam = Trim(objExcel.Cells(intRow, 1).Value)
strCN = Trim(objExcel.Cells(intRow, 2).Value)
strFirst = Trim(objExcel.Cells(intRow, 3).Value)
strPWD = Trim(objExcel.Cells(intRow, 4).Value)

' Build the actual User from data in strSheet.
Set objUser = objContainer.Create("User", "cn=" & strUser)
objUser.sAMAccountName = strSam
objUser.givenName = strFirst

' Separate section to enable account with its password
objUser.userAccountControl = 512
objUser.pwdLastSet = 0
objUser.SetPassword strPWD

intRow = intRow + 1

WScript.Echo userCount & " Users created."

' End of free example UserSpreadsheet VBScript.


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums