Re: List all DC in AD-domain and version of its OS
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 18 Jun 2009 08:41:35 -0500
"David Kriz" <Dakr@xxxxxxxx> wrote in message
news:u41FaZ%237JHA.6004@xxxxxxxxxxxxxxxxxxxxxxx
Please,
how can I list all computers account (its "Name", "DNSname", "Operating
system", "Service Pack version") which are "domain controllers" (DC) in
AD-domain?
I already have this script:
/--------------------------------- 8< ---------------------------------\
' Template:
http://windowsitpro.com/article/articleid/50071/how-can-i-list-all-domain-controllers-dcs-for-an-active-directory-ad-domain.html
Const ADS_SCOPE_SUBTREE = 2
Const InCounterB = True
If Wscript.Arguments.Count < 1 Then
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
LdapQueryS = strConfigurationNC
Else
strDomainName = Wscript.Arguments(0)
LdapQueryS ="cn=Configuration," & strDomainName
End If
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand = CreateObject("ADODB.Command")
Set objCOmmand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://" &
LdapQueryS & "' WHERE objectClass='nTDSDSA'"
Wscript.Echo "*** Input LDAP-query is: " & objCommand.CommandText
Wscript.Echo
Wscript.Echo "Next servers are Active Directory Domain Controllers: "
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
i = 0
Do Until objRecordSet.EOF
i = i + 1
S = objRecordSet.Fields("distinguishedName").Value
DomainController = Mid(S,21,InStr(Mid(S,21),",")-1)
DomainController = S
If InCounterB Then
S = CStr(i) & "."
Else
S = ""
End If
Wscript.Echo S & DomainController
objRecordSet.MoveNext
Loop
Set objParent = Nothing
Set objRecordSet = Nothing
Set objCommand = Nothing
Set objConnection = Nothing
Set objRootDSE = Nothing
\--------------------------------- 8< ---------------------------------/
but unfortunately I don't know how to get rest of informations (like
"DNSname", "Operating system", "Service Pack version").
:-(
This example VBScript program should help:
http://www.rlmueller.net/Inventory.htm
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
.
- Follow-Ups:
- Re: List all DC in AD-domain and version of its OS
- From: Richard Mueller [MVP]
- Re: List all DC in AD-domain and version of its OS
- References:
- List all DC in AD-domain and version of its OS
- From: David Kriz
- List all DC in AD-domain and version of its OS
- Prev by Date: List all DC in AD-domain and version of its OS
- Next by Date: Re: List all DC in AD-domain and version of its OS
- Previous by thread: List all DC in AD-domain and version of its OS
- Next by thread: Re: List all DC in AD-domain and version of its OS
- Index(es):