enumerating computers
- From: Tcs <TSmithATEastPointCityDOTorg@>
- Date: Wed, 26 Oct 2005 13:21:20 -0400
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
.
- Follow-Ups:
- Re: enumerating computers
- From: /\\/\\o\\/\\/
- Re: enumerating computers
- Prev by Date: Re: Archive Files
- Next by Date: Gestion des logs par Script et objet IIS ???
- Previous by thread: AccountExpirationDate
- Next by thread: Re: enumerating computers
- Index(es):
Relevant Pages
|
Loading