Link to home
Start Free TrialLog in
Avatar of internetsavant
internetsavantFlag for United States of America

asked on

Enumerate objects within Domain Computers?

i want to be able to loop through all of the computers within Domain Computers.  when i run the code listed, it will successfully work for every me-created group (e.g. myTestComputerGroup, etc) but when i run it against, Domain Computers, I get:  "The directory property cannot be found in the cache."  So i ran Active Directory Explorer to see the differences and they are apparently striking.  Normal groups keep a list of their members in an attribute called "member."  However, my Domain Computers group does not have a "member" attribute and from Active Directory Explorer I can even tell what computers are in it (and yes, there are some).  Does anyone know why this is or how I can loop through all of the computers in Domain Computers?  ADUC can obviously do it...  o.O
Option Explicit
Dim strMember, strDNSDomain, strContainer
Dim objGroup, objRootDSE
Dim arrMemberOf
 
strContainer = "cn=Domain Computers,cn=Users, "
Set objRootDSE = GetObject("LDAP://rootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
 
WScript.Echo "LDAP://"& strContainer & strDNSDomain
 
Set objGroup = GetObject("LDAP://"& strContainer & strDNSDomain)
objGroup.getInfo
 
arrMemberOf = objGroup.GetEx("member")
 
WScript.Echo "Members of Group " & strContainer
For Each strMember in arrMemberOf
   WScript.echo strMember
Next
 
Wscript.Quit

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Krys_K
Krys_K
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To help you get started and build an ADO script with what you need, have a look at this excellent site by Richard Mueller ADO Search Tips
Regards
Krystian