bjblackmore
Programmer
Hi,
I need a vbscript that will update a single attribute for all users in an OU & subOU.
I've found a couple of vbscripts online, one which updates user attributes based on an array of users listed (having to manually create the array), and another which searches & lists all users in an OU & SubOU. So I have been trying to merge these 2 scripts, but without success. Can anyone tell me where I am going wrong?
The error i'm getting is invalid syntax on line ''Set objUser = GetObject (objRecordSet.Fields("Name").Value)'
Any help greatly appreciated
Ben
I need a vbscript that will update a single attribute for all users in an OU & subOU.
I've found a couple of vbscripts online, one which updates user attributes based on an array of users listed (having to manually create the array), and another which searches & lists all users in an OU & SubOU. So I have been trying to merge these 2 scripts, but without success. Can anyone tell me where I am going wrong?
Code:
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
Set rootDSE = GetObject("LDAP://RootDSE")
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT Name FROM 'LDAP://OU=testing,OU=users,OU=London,OU=Regional,dc=domain,dc=net' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
Set objUser = GetObject (objRecordSet.Fields("Name").Value)
objUser.Put "l", "London"
objUser.SetInfo
objRecordSet.MoveNext
Loop
objRecordSet.Close
Set objRecordSet = Nothing
Set objCommand = Nothing
objConnection.Close
Set objConnection = Nothing
WSCript.Quit
The error i'm getting is invalid syntax on line ''Set objUser = GetObject (objRecordSet.Fields("Name").Value)'
Any help greatly appreciated
Ben