I am new to scripting and am having a problem getting this script to work. I want to first find all the computers in ADUC and then list all the local admins of those computers in a text file. Here is what I have so far. Any help will be appreciated. Thanks.
Const ADS_SCOPE_SUBTREE = 2
Set ws = CreateObject("WScript.Shell"
Set objConnection = CreateObject("ADODB.Connection"
Set objCommand = CreateObject("ADODB.Command"
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT Name, Location FROM 'LDAP://OU=Test,DC=domain,DC=com' WHERE objectClass='computer'"
objCommand.Properties("Page Size" = 1000
objCommand.Properties("Timeout" = 30
objCommand.Properties("Searchscope" = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results" = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Sleep 15000
Perm = ws.run("c:\local.exe administrators \\" & objRecordSet.Fields("name".Value & "">"" c:\localadmin.txt"
'Wscript.Echo "Computer Name: " & objRecordSet.Fields("name".Value
objRecordSet.MoveNext
Loop
Set ws = Nothing
Set objConnection = Nothing
Set objCommand = Nothing
Set objRecordSet = Nothing
Const ADS_SCOPE_SUBTREE = 2
Set ws = CreateObject("WScript.Shell"
Set objConnection = CreateObject("ADODB.Connection"
Set objCommand = CreateObject("ADODB.Command"
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT Name, Location FROM 'LDAP://OU=Test,DC=domain,DC=com' WHERE objectClass='computer'"
objCommand.Properties("Page Size" = 1000
objCommand.Properties("Timeout" = 30
objCommand.Properties("Searchscope" = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results" = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Sleep 15000
Perm = ws.run("c:\local.exe administrators \\" & objRecordSet.Fields("name".Value & "">"" c:\localadmin.txt"
'Wscript.Echo "Computer Name: " & objRecordSet.Fields("name".Value
objRecordSet.MoveNext
Loop
Set ws = Nothing
Set objConnection = Nothing
Set objCommand = Nothing
Set objRecordSet = Nothing