Print zone list (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.

' Print the list of zones on a server

' ---------------------------------------------------------------
' 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
' ---------------------------------------------------------------

strServer   = "terminator.movie.edu"
strUsername = "dnsadmin"
strPassword = "dnspwd"

Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objDNS = objLocator.ConnectServer(strServer, "root\MicrosoftDNS", _
                                      strUsername, strPassword)
set objDNSServer = objDNS.Get("MicrosoftDNS_Server.Name="".""")
set objZones = objDNS.ExecQuery("Select * from MicrosoftDNS_Zone " & _
                                "Where DnsServerName = '" & _
                                objDNSServer.Name & "'") 
WScript.Echo objDNSServer.Name
for each objZone in objZones
   WScript.Echo " " & objZOne.Name
next

This code has been viewed 1480 times.

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