Anyone?
domain="yourdomain"
domain2="com"
On Error Resume Next
Set MyObject = GetObject("LDAP://OU=Domain Controllers,DC=" & domain &
",DC=" & domain2 )
if err<>0 then
if err<>-2147016656 then wscript.echo "unexpected error getting DCs"
else
On Error Goto 0
Set Container = MyObject
For Each Child in Container
Wscript.echo "DC: " & right( Child.Name, len(Child.Name)-3 )
Next
End If
Set oDC = GetObject("LDAP://ou=Domain
Controllers,dc=MyDomain,dc=com")
For Each oServer In oDC
MsgBox oServer.Name
Next
I don't have any member servers, so I don't know where
they show up. If they are in cn=Computers, perhaps you can
find a property ("ObjectClass" or "MachineRole") in ADSI
Edit that can be used to indicate which computers are
member servers.
Richard
>.
>
Geesh! Is it really this difficult to enumerate all servers in the Active
Directory using ADSI?
"Richard Mueller" <RLMu...@ameritech.net> wrote in message
news:1d4801c1b0d9$8ac34790$35ef2ecf@TKMSFTNGXA11...
patrick
"Larry A Duncan" <sms...@hotmail.com> wrote in message
news:#TzJpyNsBHA.1708@tkmsftngp03...
' Get the Configuration Naming Context
Set oRootDSE = GetObject("LDAP://RootDSE")
strConfigNC = oRootDSE.Get("configurationNamingContext")
' Set up the oConnectionection
set oConnection = CreateObject("ADODB.Connection")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "ADs Provider"
' Build the query to find all Exchange ServeoRecordset
strQuery = "<LDAP://" & strConfigNC &
">;(objectClass=nTDSDSA);ADsPath;subtree"
set oCmd = CreateObject("ADODB.Command")
oCmd.ActiveConnection = oConnection
oCmd.CommandText = strQuery
Set oRecordset = oCmd.Execute
' Iterate through the results
If oRecordset.Eof and oRecordSet.Bof Then
WScript.Echo "No Domain Controllers were found"
Else
While Not oRecordset.EOF
Set oParent = GetObject(GetObject(oRecordset.Fields("ADsPath")).Parent)
' Output the name of the server
WScript.Echo "Server: " & oParent.cn & " dNSHostName: " &
oParent.dNSHostName
oRecordset.MoveNext
Wend
End if
Dave Stucki
Microsoft Developer Support
This posting is provided “AS IS” with no warranties, and confers no rights.
My only suggestion is to use NetServerEnum, but this relies on the
Windows browse list.
Kevin Stanush
SystemTools Software Inc.
http://www.systemtools.com
Home of 'Hyena' for Windows NT/2000 System Administration
"Larry A Duncan" <sms...@hotmail.com> wrote in message news:<#TzJpyNsBHA.1708@tkmsftngp03>...
pat
"Kevin Stanush" <ke...@systemtools.com> wrote in message
news:8b0a3be0.02021...@posting.google.com...