Skip to content
Menu

Windows DNS Server - Forwarders, Aging and Scavenging

Reports this DNS server's forwarders (and whether each answers a test query), server scavenging, and aging for every primary zone. Read-only, one row per setting.

Windows DNS server - forwarders, aging and scavenging is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Windows DNS server - forwarders, aging and scavenging. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows Server 2016+ (DNS Server role); runs as SYSTEM
NeedsPowerShell 5.1, administrator rights, DnsServer module (RSAT-DNS-Server), run on the DNS server
Read-onlyReads, changes nothing

What It Does

The script writes one row per setting in three sections. Forwarders lists each forwarder address, the forwarder time-out and whether root hints are used when forwarders fail. Unless TestForwarders is false it also sends a query for TestName straight to each forwarder and shows whether it answered and how long it took.

Scavenging shows whether server-wide scavenging is on, how often it runs, the default no-refresh and refresh intervals and the last time it ran. Zones lists, for every primary zone that was not created automatically, whether aging is on, its intervals and which servers scavenge it.

Aging only removes old records when it is on for the zone and scavenging is on for at least one server. The answer states both. The report does not alert on the settings it finds or change them. Use the DNS console or Set-DnsServerScavenging to make a change.

If the DNS Server service is not installed it ends SKIPPED, and without the DnsServer module it ends ERROR.

Before You Run It

  • Run it on the DNS server itself, with administrator rights and the DnsServer module (RSAT-DNS-Server).
  • Set TestName to a name your forwarders should always resolve. The default is www.microsoft.com.
  • Set TestForwarders to false on a server that cannot send queries out directly.
  • Do not read a quiet table as healthy. Compare the aging and scavenging rows with how often you see stale records.

Type and Risk

  • Type: Report. It collects facts into a table and never alerts. It exits 0, or 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: Under 30 seconds.
  • Example answer: "DNS server DC1: 2 forwarder(s), 2 answer; scavenging on every 7 days; aging on in 3 of 5 zone(s)"
  • Tested before listing on a Windows Server 2025 domain controller (VM) with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • TestForwarders: true to send a test query to every forwarder. Default true.
  • TestName: The name to look up through each forwarder. Default www.microsoft.com.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

get-dns-server-config.ps1 · 841 lines · 43.6 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.