enumerating computers



I'm trying to use the following code, which I've obtained from:

http://www.microsoft.com/technet/scriptcenter/guide/sas_srv_lxfr.mspx

Const ADS_SCOPE_SUBTREE = 2
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://DC=fabrikam,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.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
objRecordSet.MoveNext
Loop

When I change "fabrikam" to one of our domain controller names, all I get back
is:

Line: 14
Char: 1
Error: Table does not exist.
Code: 80040E37
Source: Provider

I have also tried running a[n alledgedly] running script which will determine
the domain name, then get all the computers. But doesn't. It too errors out,
displaying a msg from within the script that either AD is unavailable, or not
reporting propertly, as it says the script itself is designed for a single
domain.

We have one old NT4 domain, with 2 DCs (NT4). We have one new domain, with 2
DCs (2k3). No trusts exist between the domains. All users have been migrated
to the new domain. Most clients and only a couple servers are still in the old
domain. Newer clients and servers are in the new domain. (We started the
migration about 6 months ago.)

I'm still very new to scripting, and I don't know if the error mentioned above
is because the code is faulty (*shouldn't* be, coming off MS's
website..riiight?), or if it's because we currently have more than one domain.
Does anyone out there know? If the former, can we fix the code? If the latter,
can the code be modified to handle multiple domains?

I appreciate the assist, thanks in advance,

Tom
.



Relevant Pages

  • Re: login scripting
    ... DC Servers are Windows 2003 Server. ... Clients are Win 2000 Pro, and a few Win XP clients. ... I observe the minimized login script on the task bar, ... already starting to process startup group items. ...
    (microsoft.public.win2000.general)
  • Re: fork,exec, and parallel processing
    ... I've a need for a script that can query multiple NetBackup servers for ... What can I do to correct the script so it ... my @clients; ... ## harvesting code from above here, ...
    (comp.lang.perl.misc)
  • Re: fork,exec, and parallel processing
    ... I've a need for a script that can query multiple NetBackup servers for ... What can I do to correct the script so it ... my @clients; ... Dump the data you need into a Database then parse the database once ...
    (comp.lang.perl.misc)
  • Re: fork,exec, and parallel processing
    ... I've a need for a script that can query multiple NetBackup servers for ... What can I do to correct the script so it ... You should also include the 'warnings' pragma. ... my @clients; ...
    (comp.lang.perl.misc)
  • Re: slow logon
    ... in the logon time have been reduced so far. ... update the time for the clients that talk to the dc as the logon server. ... start up script in AD to apply updates to the clients machines which is ...
    (microsoft.public.windows.server.active_directory)

Loading