Perform an SRV record query (VBScript)

This code can be found in Chapter 14 of DNS on Windows Server 2003

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' Perform an SRV record query

' ---------------------------------------------------------------
' From the book "DNS on Windows Server 2003" 
' By Cricket Liu, Matt Larson & Robbie Allen
' Publisher: O'Reilly and Associates
' ISBN: 0-596-00562-8
' Book web site: http://rallenhome.com/books/dnsonw2k3/toc.html
' ---------------------------------------------------------------

option explicit

Dim strDomain
strDomain = "movie.edu"

Dim objDNS, objRRs, objRR
set objDNS = GetObject("winMgmts:root\MicrosoftDNS")
set objRRs = objDNS.ExecQuery("Select * from MicrosoftDNS_SRVType " & _
                             " Where OwnerName = '_ldap._tcp.gc._msdcs." & _ 
                             strDomain & "'")
WScript.Echo "Global Catalogs for " & strDomain
for Each objRR in objRRs
   Wscript.Echo " " & objRR.DomainName
next

Wscript.Echo

set objRRs = objDNS.ExecQuery("Select * from MicrosoftDNS_SRVType " & _
                             " Where OwnerName = '_ldap._tcp.dc._msdcs." & _
                             strDomain & "'")  
WScript.Echo "Domain Controllers for " & strDomain
for Each objRR in objRRs
   Wscript.Echo " " & objRR.DomainName
next

This code has been viewed 3329 times.

New from the creators of TechTasks.com: StatSheet.com