Shortcut Menu

Skip

Main Navigation

Choose your language

You are here:

ActiveXperts.com > Network Monitor > WindowsManagement > Scripts > Networking > DNS Server > DNS Server Management Tasks

ActiveXperts Network Monitor
Monitor servers, workstations, devices and applications in your network

Quicklinks


Retrieving DNS Server Management Information - Sample Scripts

Age All DNS Records
Clear the DNS Server Cache
Create a Primary DNS Zone
Force a Refresh of a DNS Zone
List DNS Server Cache Properties
List DNS Server Properties
List DNS Server Root Hints Properties
List DNS Server Statistics
List DNS Zones
Modify the DNS Zone Type
Pause a DNS Zone
Reload a DNS Zone
Resume a Paused DNS Zone
Start DNS Server Scavenging
Start the DNS Server Service
Stop the DNS Server Service
Update a DNS Zone
Write-Back a DNS Zone


You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.



Age All DNS Records


Enables aging of all records (except name server and start of authority records) in the DNS zone accounting.fabrikam.com.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    errResult = objItem.AgeAllRecords(,1)
Next
	

Clear the DNS Server Cache


Clears the DNS server cache of resource records.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * From MicrosoftDNS_Cache")

For Each objItem in colItems
    objItem.ClearCache()
Next
	

Create a Primary DNS Zone


Creates a primary DNS zone named accounting.fabrikam.com on a DNS server.
strZoneName = "accounting.fabrikam.com"
intPrimaryZone = 1
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_Zone")
errResult = objItem.CreateZone(strZoneName, intPrimaryZone)
	

Force a Refresh of a DNS Zone


Forces the refresh of the secondary DNS zone accounting.fabrikam.com from its master zone.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    objItem.ForceRefresh()
Next
	

List DNS Server Cache Properties


Returns information about the DNS cache on a DNS server.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_Cache")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DNSServerName
    Wscript.Echo
Next
	

List DNS Server Properties


Returns detailed information about a DNS server.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_Server")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Address Answer Limit: " & objItem.AddressAnswerLimit
    Wscript.Echo "Allow Update: " & objItem.AllowUpdate
    Wscript.Echo "Autocache Update: " & objItem.AutoCacheUpdate
    Wscript.Echo "Autoconfig File Zones: " & objItem.AutoConfigFileZones
    Wscript.Echo "Bind Secondaries: " & objItem.BindSecondaries
    Wscript.Echo "Boot Method: " & objItem.BootMethod
    Wscript.Echo "Default Aging State: " & objItem.DefaultAgingState
    Wscript.Echo "Default No-Refresh Interval: " & _
        objItem.DefaultNoRefreshInterval
    Wscript.Echo "Default Refresh Interval: " & objItem.DefaultRefreshInterval
    Wscript.Echo "Disable AutoReverse Zones: " & _
        objItem.DisableAutoReverseZones
    Wscript.Echo "Disjoint Nets: " & objItem.DisjointNets
    Wscript.Echo "Directory Service Available: " & objItem.DsAvailable
    Wscript.Echo "Directory Service Polling Interval: " & _
        objItem.DsPollingInterval
    Wscript.Echo "Directory Service Tombstone Interval: " & _
        objItem.DsTombstoneInterval
    Wscript.Echo "EDNS Cache Timeout: " & objItem.EDnsCacheTimeout
    Wscript.Echo "Enable Directory Partitions: " & _
        objItem.EnableDirectoryPartitions
    Wscript.Echo "Enable DNSSec: " & objItem.EnableDnsSec
    Wscript.Echo "Enable EDNS Probes: " & objItem.EnableEDnsProbes
    Wscript.Echo "Event Log Level: " & objItem.EventLogLevel
    Wscript.Echo "Forward Delegations: " & objItem.ForwardDelegations
    Wscript.Echo "Forwarders: " & objItem.Forwarders
    Wscript.Echo "Forwarding Timeout: " & objItem.ForwardingTimeout
    Wscript.Echo "Is Slave: " & objItem.IsSlave
    Wscript.Echo "Listen Addresses: " & objItem.ListenAddresses
    Wscript.Echo "Local Net Priority: " & objItem.LocalNetPriority
    Wscript.Echo "Logfile Maximum Size: " & objItem.LogFileMaxSize
    Wscript.Echo "Logfile Path: " & objItem.LogFilePath
    Wscript.Echo "Log IPFilter List: " & objItem.LogIPFilterList
    Wscript.Echo "Log Level: " & objItem.LogLevel
    Wscript.Echo "Loose Wildcarding: " & objItem.LooseWildcarding
    Wscript.Echo "Maximum Cache Time-to-Live: " & objItem.MaxCacheTTL
    Wscript.Echo "Maximum Negative Cache Time-to-Live: " & _
        objItem.MaxNegativeCacheTTL
    Wscript.Echo "Name Check Flag: " & objItem.NameCheckFlag
    Wscript.Echo "No Recursion: " & objItem.NoRecursion
    Wscript.Echo "Recursion Retry: " & objItem.RecursionRetry
    Wscript.Echo "Recursion Timeout: " & objItem.RecursionTimeout
    Wscript.Echo "RoundRobin: " & objItem.RoundRobin
    Wscript.Echo "Rpc Protocol: " & objItem.RpcProtocol
    Wscript.Echo "Scavenging Interval: " & objItem.ScavengingInterval
    Wscript.Echo "Secure Responses: " & objItem.SecureResponses
    Wscript.Echo "Send Port: " & objItem.SendPort
    For Each strAddress in objItem.ServerAddresses
        Wscript.Echo "Server Address: " & strAddress
    Next
    Wscript.Echo "Started: " & objItem.Started
    Wscript.Echo "Start Mode: " & objItem.StartMode
    Wscript.Echo "Strict File Parsing: " & objItem.StrictFileParsing
    Wscript.Echo "Update Options: " & objItem.UpdateOptions
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo "Write Authority NS: " & objItem.WriteAuthorityNS
    Wscript.Echo "Xfr Connect Timeout: " & objItem.XfrConnectTimeout
Next
	

List DNS Server Root Hints Properties


Returns information about the root hints stored in the cache file on a DNS server.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_RootHints")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo
Next
	

List DNS Server Statistics


Returns statistics collected on a DNS server.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_Statistic")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Collection Name: " & objItem.CollectionName
    Wscript.Echo "Collection ID: " & objItem.CollectionId
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "String Value: " & objItem.StringValue
    Wscript.Echo "Value: " & objItem.Value
    Wscript.Echo
Next
	

List DNS Zones


Returns information about all the DNS zones on a DNS server.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_Zone")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Zone Type: " & objItem.ZoneType
    Wscript.Echo "Aging: " & objItem.Aging
    Wscript.Echo "Allow Update: " & objItem.AllowUpdate
    Wscript.Echo "Autocreated: " & objItem.AutoCreated
    Wscript.Echo "Available For Scavenge Time: " & _
        objItem.AvailForScavengeTime
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "Data File: " & objItem.DataFile
    Wscript.Echo "Disable WINS Record Replication: " & _
        objItem.DisableWINSRecordReplication
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Directory Service-Integrated: " & objItem.DsIntegrated
    Wscript.Echo "Forwarder Slave: " & objItem.ForwarderSlave
    Wscript.Echo "Forwarder Timeout: " & objItem.ForwarderTimeout
    Wscript.Echo "Last Successful SOA Check: " & _
        objItem.LastSuccessfulSoaCheck
    Wscript.Echo "LastSuccessful Xfr: " & objItem.LastSuccessfulXfr
    Wscript.Echo "Local Master Servers: " & objItem.LocalMasterServers
    Wscript.Echo "Master Servers: " & objItem.MasterServers
    Wscript.Echo "No-Refresh Interval: " & objItem.NoRefreshInterval
    Wscript.Echo "Notify: " & objItem.Notify
    Wscript.Echo "Notify Servers: " & objItem.NotifyServers
    Wscript.Echo "Paused: " & objItem.Paused
    Wscript.Echo "Refresh Interval: " & objItem.RefreshInterval
    Wscript.Echo "Reverse: " & objItem.Reverse
    Wscript.Echo "Scavenge Servers: " & objItem.ScavengeServers
    Wscript.Echo "Secondary Servers: " & objItem.SecondaryServers
    Wscript.Echo "Secure Secondaries: " & objItem.SecureSecondaries
    Wscript.Echo "Shutdown: " & objItem.Shutdown
    Wscript.Echo "Use Wins: " & objItem.UseWins
    Wscript.Echo
Next
	

Modify the DNS Zone Type


Changes the DNS zone type of the zone accounting.fabrikam.com to a primary DNS zone.
intPrimaryZone = 1
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    errResult = objItem.ChangeZoneType(intPrimaryZone, true)
Next
	

Pause a DNS Zone


Pauses the DNS zone accounting.fabrikam.com.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    objItem.PauseZone()
Next
	

Reload a DNS Zone


Reloads the DNS zone fabrikam.com from its database.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'fabrikam.com'")

For Each objItem in colItems
    objItem.ReloadZone()
Next
	

Resume a Paused DNS Zone


Resumes the DNS zone accounting.fabrikam.com.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    objItem.ResumeZone()
Next
	

Start DNS Server Scavenging


Instructs a DNS server to begin scavenging stale records in the appropriate DNS zones.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * From MicrosoftDNS_Server")

For Each objItem in colItems
    objItem.StartScavenging()
Next
	

Start the DNS Server Service


Starts the DNS server service on a computer.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * From MicrosoftDNS_Server")

For Each objItem in colItems
    objItem.StartService()
Next
	

Stop the DNS Server Service


Stops the DNS server service.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * From MicrosoftDNS_Server")

For Each objItem in colItems
    objItem.StopService()
Next
	

Update a DNS Zone


Forces an update of the DNS zone accounting.fabrikam.com from Active Directory.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    objItem.UpdateFromDS()
Next
	

Write-Back a DNS Zone


Saves zone data for the DNS zone accounting.fabrikam.com to the appropriate zone file.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    objItem.WriteBackZone()
Next