Enumerating computers in a given Win2k AD Domain
Keywords: Enumerating computers Win2k AD domain
Question:
Please help! I'm not a newbie to Winbatch however am a newbie to Windows 2000 / AD. All I need to do is just list all the computer names in a Windows 2000 domain regardless if the computers are in the default computers container or under other OUs.I'll appreciate if someone can post a sample script please. Many thanks in advance.
Answer:
Here's how it is done using the ADSI extender.AddExtender("wwads34I.dll") ; Set credentials dsSetCredent("Buda", "********") sAdsiPath = "LDAP://MyDomain" ; Get all computers sSearch = "objectCategory=computer" lPaths= dsFindPath(sAdsiPath, sSearch) lCompNames = "" ; Need to initialize. nCount = ItemCount(lPaths, @Tab) for i=1 to nCount ; Get the common name. sPath = ItemExtract(i, lPaths, @Tab) sCompName = dsGetProperty(sPath, "cn") lCompNames = ItemInsert(sCompName,-1, lCompNames, @Tab) next ; Display the results. lCompNames = strreplace(lCompNames,@TAB, @CRLF) Message("Computers", lCompNames)
Article ID: W14510Filename: Enumerating computers in a Win2k AD domain.txt