matt1982
asked on
Adding home directories to each user in script
Ok, looking for suggestions on ways to add the functionality of creating home directories to a script I have for creating users. Here is the current script i have:
************************** ********** ********** ********** **********
' UserSpreadsheet .vbs
' Sample VBScript to create User accounts from a spreadsheet
' Author Guy Thomas http://computerperformance.co.uk/
' Version 4.6 - June 2005
' -------------------------- ---------- ---------- --------'
Option Explicit
Dim objRootLDAP, objContainer, objUser, objShell
Dim objExcel, objSpread, intRow
Dim strUser, strOU, strSheet, i
Dim strCN, strSam, strFirst, strLast, strPWD, strDesc, StrDis
' -------------------------- ---------- ---------- ---------- -----'
' Important change OU= and strSheet to reflect your domain
' -------------------------- ---------- ---------- ---------- -----'
strOU = "OU=Students, OU=AEC, OU=03 Schools," ' Note the comma
strSheet = "c:\creating users\aec\aectemp.xml"
' Bind to Active Directory, Users container.
Set objRootLDAP = GetObject("LDAP://rootDSE" )
Set objContainer = GetObject("LDAP://" & strOU & _
objRootLDAP.Get("defaultNa mingContex t"))
' Open the Excel spreadsheet
Set objExcel = CreateObject("Excel.Applic ation")
Set objSpread = objExcel.Workbooks.Open(st rSheet)
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).V alue = ""
strSam = Trim(objExcel.Cells(intRow , 1).Value)
strCN = Trim(objExcel.Cells(intRow , 1).Value)
strFirst = Trim(objExcel.Cells(intRow , 2).Value)
strLast = Trim(objExcel.Cells(intRow , 3).Value)
strPWD = Trim(objExcel.Cells(intRow , 4).Value)
strDesc = Trim(objExcel.cells(intRow , 5).value)
strDis = 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.Put "DisplayName", strDis
objUser.SetInfo
' Separate section to enable account with its password
objUser.userAccountControl = 512
objUser.ChangePassword "", strPWD
objUser.SetInfo
intRow = intRow + 1
i = i + 1
Loop
objExcel.Quit
WScript.Echo "Finished Creating Users. " & i & " Users created!"
WScript.Quit
' End of Sample UserSpreadsheet VBScript.
************************** ********** ********** ********** *********
Thanks in advance.
**************************
' UserSpreadsheet .vbs
' Sample VBScript to create User accounts from a spreadsheet
' Author Guy Thomas http://computerperformance.co.uk/
' Version 4.6 - June 2005
' --------------------------
Option Explicit
Dim objRootLDAP, objContainer, objUser, objShell
Dim objExcel, objSpread, intRow
Dim strUser, strOU, strSheet, i
Dim strCN, strSam, strFirst, strLast, strPWD, strDesc, StrDis
' --------------------------
' Important change OU= and strSheet to reflect your domain
' --------------------------
strOU = "OU=Students, OU=AEC, OU=03 Schools," ' Note the comma
strSheet = "c:\creating users\aec\aectemp.xml"
' Bind to Active Directory, Users container.
Set objRootLDAP = GetObject("LDAP://rootDSE"
Set objContainer = GetObject("LDAP://" & strOU & _
objRootLDAP.Get("defaultNa
' Open the Excel spreadsheet
Set objExcel = CreateObject("Excel.Applic
Set objSpread = objExcel.Workbooks.Open(st
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).V
strSam = Trim(objExcel.Cells(intRow
strCN = Trim(objExcel.Cells(intRow
strFirst = Trim(objExcel.Cells(intRow
strLast = Trim(objExcel.Cells(intRow
strPWD = Trim(objExcel.Cells(intRow
strDesc = Trim(objExcel.cells(intRow
strDis = Trim(objExcel.cells(intRow
' Build the actual User from data in strSheet.
Set objUser = objContainer.Create("User"
objUser.sAMAccountName = strSam
objUser.givenName = strFirst
objUser.sn = strLast
objUser.Put "DisplayName", strDis
objUser.SetInfo
' Separate section to enable account with its password
objUser.userAccountControl
objUser.ChangePassword "", strPWD
objUser.SetInfo
intRow = intRow + 1
i = i + 1
Loop
objExcel.Quit
WScript.Echo "Finished Creating Users. " & i & " Users created!"
WScript.Quit
' End of Sample UserSpreadsheet VBScript.
**************************
Thanks in advance.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thankyou