Print name server properties (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 all the properties of a name 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"

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

This code has been viewed 1592 times.

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