December 2003
Intermediate to advanced
416 pages
13h 50m
English
The last zone example we’ll
show
lists the configured zones on a specific name server. To make the
following example a little more robust, we’ve added
logic to make the script configurable so it can be run against any
name server using the specified credentials. That is accomplished by
using the ConnectServer method on the
SWbemLocator object.
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
nextTo retrieve the list of zones, we used a WQL query with
ExecQuery to find all
MicrosoftDNS_Zone objects that had a
DnsServerName equal to the name of the server we
are connecting
to.
Read now
Unlock full access