teddysherri
Technical User
Hi Guys,
I have been asked to find the FQDN and IP address of all the domain controllers in our domain. I think there is roughly about 150 odd so i don't want to sit here all day pinging each one, so is there a script which i can run that will be able to gather the info for me? I have the below script but it just gives me the name and not the FQDN or IP, is there a way of modifying it to give me the information i need?
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT ADsPath FROM 'LDAP://" & strConfigurationNC & "' WHERE objectClass='nTDSDSA'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Set objParent = GetObject(GetObject(objRecordset.Fields("ADsPath")).Parent)
WScript.Echo objParent.CN
objRecordSet.MoveNext
Loop
Thank you.
I have been asked to find the FQDN and IP address of all the domain controllers in our domain. I think there is roughly about 150 odd so i don't want to sit here all day pinging each one, so is there a script which i can run that will be able to gather the info for me? I have the below script but it just gives me the name and not the FQDN or IP, is there a way of modifying it to give me the information i need?
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT ADsPath FROM 'LDAP://" & strConfigurationNC & "' WHERE objectClass='nTDSDSA'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Set objParent = GetObject(GetObject(objRecordset.Fields("ADsPath")).Parent)
WScript.Echo objParent.CN
objRecordSet.MoveNext
Loop
Thank you.