Re: How to detect all domain machines with script?

From: Scott Cooper (scooper02@earthlink.net)
Date: 11/20/02


From: "Scott Cooper" <scooper02@earthlink.net>
Date: Tue, 19 Nov 2002 15:34:55 -0800


In each domain you can enumerate the domain controllers OU (this is the
easiest method).
set DCList = GetObject(LDAP://ou=domain controllers, dc=domain, dc=com)
For each DCObj in DCList
    servername = DCObj.cn

Next

Or if you want all domain controllers in the forest, I suggest using an ADO
method. This method will look for the site server object in the
configuration partition.

Set oRoot = GetObject("LDAP://RootDSE")
sDNSDomain = "cn=configuration," & oRoot.Get("rootDomainNamingContext")

Set oCmd = CreateObject("ADODB.Command")
Set oCon = CreateObject("ADODB.Connection")
oCon.Provider = "ADsDSOObject"
oCon.Open = "Active Directory Provider"
oCmd.ActiveConnection = oCon
sQuery = "SELECT Name FROM 'LDAP://" _
  & sDNSDomain & "' WHERE objectCategory = 'server'"
oCmd.CommandText = sQuery
oCmd.Properties("Searchscope") = 2
oCmd.Properties("Cache Results") = False
Set oRS = oCmd.Execute

While not oRS.EOF
  wscript.echo oRS.Fields("Name")
  oRS.MoveNext
Wend

"A. Tolga KILINĒ" <kilinc@tis.havelsan.com.tr> wrote in message
news:OLKF0sviCHA.1652@tkmsftngp11...
> Hi,
> How can I detect all domain machines with an ADSI script? Is there any
> example script for this?
> Regards,
> Tolga
>
>
>



Relevant Pages

  • Re: Backup AD
    ... was unable to convert the computer account $ to a domain ... Default Domain Controllers Policy on the Domain Controllers ... Replicate Now feature to force replication from the domain controller ... >permission to update the servername$ to Domain Controller. ...
    (microsoft.public.backoffice.smallbiz2000)
  • The DC Locator service is not advertising.(!?)
    ... One of our Domain Controllers is prompting warning messages to MOM: ... The DC Locator service is not advertising. ... This means that no clients ... When queried, the DC Locator returned a remote DC (servername), ...
    (microsoft.public.windows.server.active_directory)
  • Re: Same two Domain Names in the same network
    ... You can have a lot of Domain controllers in one domain, or did you mean the same servername? ... So please clarify a bit your naming problem. ... Domain name, network name, name of domain controller and name of Exchange server. ...
    (microsoft.public.win2000.dns)
  • RE: CSVDE Problem
    ... I am not using the -s [servername] option because I am ... running from one of the domain controllers. ... >> The csvde script gets no errors when it runs, ... Prev by Date: ...
    (microsoft.public.windows.server.active_directory)