Hi
I'm new to this forum so please bear with me.
I have setup a script ( note I didn't write the whole thing , kinda of a noob with regards to vbs)
the script is as follows
Option ExplicitDim objRootLDAP, objContainer, objUser, objShell
Dim objExcel, objSpread, intRow
Dim strUser, strOU, strSheet
Dim strCN, strSam, strFirst, strLast, strDescription, strPWD
' -------------------------------------------------------------'
' Important change OU= and strSheet to reflect your domain
' -------------------------------------------------------------'
strOU = "OU=Cp1, OU=Part_Time," ' Note the comma
strSheet = "C:\scripts\NewStatus.xls"
' Bind to Active Directory, Users container.
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://" & strOU & _
objRootLDAP.Get("defaultNamingContext"))
' Open the Excel spreadsheet
Set objExcel = CreateObject("Excel.Application")
Set objSpread = objExcel.Workbooks.Open(strSheet)
intRow = 2 '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)
strLast = Trim(objExcel.Cells(intRow, 4).Value)
strDescription = Trim(objExcel.Cells(intRow, 5).Value)
strPWD = Trim(objExcel.Cells(intRow, 6).Value)
' Build the actual User from data in strSheet.
Set objUser = objContainer.Create("User", "cn=" & strCN)
objUser.sAMAccountName = strSam
objUser.givenName = strFirst
objUser.sn = strLast
objUser.Description = strDescription
objUser.SetInfo
' Separate section to enable account with its password
objUser.userAccountControl = 512
objUser.pwdLastSet = -1
objUser.SetPassword strPWD
objUser.SetInfo
intRow = intRow + 1
Loop
objExcel.Quit
WScript.Quit
Trying to figure out how to add a "if found then next" type of code.
In short I get xl files from HR and usually have to push users into AD, the problem is that sometimes I bump into Users that already exist in the Active Directory.
Anyone kind enough to help out? (I applogise for spelling mistakes, , currently stuck on a 10 inch screen Notebook)