Hi All
i am installing a new windows server 2008 server in a school this summer and i am having a problem with the scripts i wrote for windows server 2003 working on 2008.
The script is addding users to AD through a csv file, creating the home directory as well as other things. When i run the script it comes up with the following error
Error – Syntax error in FROM clause
Code – 80040E14
Source – Microsoft Jet Engine Database
Line 17
Char 1
If anyone could help i would be much appreciated.
Here is the script below
Dim sCSVFileLocation, sCSVFile, oConnection, oRecordSet, oNewUser, oRootLDAP, oContainer, sLogon, sFirstName, sLastName
Dim sDisplayName, sPassword, nPwdLastSet, nUserAccountControl, sDomain, HomeDriveServerPath, HomeDriveLetter, objFSO
Dim objFolder, oshell
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set oShell = wscript.CreateObject(“Wscript.Shell”)
sDomain =”swdomain.local”
sCSVFileLocation = “C:\scripts\”
sCSVFile = sCSVFileLocation&”year5.csv”
set oConnection = createobject(“adodb.connection”)
set oRecordSet = createobject(“adodb.recordset”)
oConnection.open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source= ” & sCSVFileLocation & “;Extended Properties=””text;HDR=NO;FMT=Delimited”””
oRecordSet.open “SELECT * FROM ” & sCSVFile ,oConnection
Set oRootLDAP = GetObject(“LDAP://rootDSE”)
Set oContainer = GetObject(“LDAP://cn=Users,” & _
oRootLDAP.Get(“defaultNamingContext”))
do until oRecordSet.EOF
sLogon = oRecordSet.Fields.Item(0).value
sFirstName = oRecordSet.Fields.Item(1).value
sLastName = oRecordSet.Fields.Item(2).value
sDisplayName = sLastName&”, “&sFirstName
sPassword = oRecordSet.Fields.Item(3).value
HomeDriveServerPath = “\\swserver\homes\” & sLogon
HomeDriveLetter = “U:”
scriptPath = “students.bat”
Set objFolder = objFSO.CreateFolder(“\\swserver\homes\” & sLogon)
Set oNewUser = oContainer.Create(“User”,”cn=”&sFirstName&” “&SLastName)
oNewUser.put “sAMAccountName”,lcase(sLogon)
oNewUser.put “givenName”,sFirstName
oNewUser.put “sn”,sLastName
oNewUser.put “UserPrincipalName”,lcase(SLogon)&”@”&sDomain
oNewUser.put “DisplayName”,sDisplayName
oNewUser.put “name”,lcase(sLogon)
oNewUser.SetInfo
oNewUser.SetPassword sPassword
oNewUser.Put “pwdLastSet”, 0
oNewUser.Put “homeDrive”, HomeDriveLetter
oNewUser.SetInfo
oNewUser.Put “homeDirectory”, HomeDriveServerPath
oNewUser.SetInfo
oNewUser.Put “scriptPath”, scriptPath
oNewUser.Setinfo
oNewUser.Put “userAccountControl”, 512
oNewUser.Put “userAccountControl”, 66048
oNewUser.SetInfo
oShell.Run “%COMSPEC% /c Echo Y| cacls \\swserver\homes\” & sLogon & ” /t /e /g Administrators:F “& Slogon & “:F”, 2, True
oRecordset.MoveNext
Loop