Listing a Name Server’s Properties
The first step to programmatically managing your name server’s configuration is to see what settings you currently have in place and determine whether any need to be modified. With WMI, it’s really easy to list all properties for a name server. The following example shows how to do it:
strServer = "terminator.movie.edu"
' Instantiate a WMI object for the target server
set objDNS = GetObject("winmgmts:\\" & strServer & "\root\MicrosoftDNS")
' Get an instance of the MicrosoftDNS_Server class
set objDNSServer = objDNS.Get("MicrosoftDNS_Server.Name="".""")
' Iterate over each property using Properties_
Wscript.Echo objDNSServer.Properties_.Item("Name") & ":"
for each objProp in objDNSServer.Properties_
if IsNull(objProp.Value) then
Wscript.Echo " " & objProp.Name & " : NULL"
else
if objProp.IsArray = TRUE then
For I = LBound(objProp.Value) to UBound(objProp.Value)
wscript.echo " " & objProp.Name & " : " & objProp.Value(I)
next
else
wscript.echo " " & objProp.Name & " : " & objProp.Value
end if
end if
nextAfter getting a WMI object for the DNS Provider
(root\MicrosoftDNS), we get a
MicrosoftDNS_Server object by looking for the
“.” instance. Since there can be
only one instance of MicrosoftDNS_Server running
on any given computer, we do not need to worry about multiple
objects. After getting a MicrosoftDNS_Server object, we iterate through all the properties of the object and print each one out. Note that we have added special checks for values that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access