Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Domain Controller Script

Status
Not open for further replies.

teddysherri

Technical User
Nov 18, 2003
137
GB
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.
 
You already have the FQDN, it is what you are getting as the ADSPath.

To get the IP address use WMI. A sample can be found here:

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top