PowerShell Genie

DnsServer module: setup and commands

Module 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Query DNS zones and records with Get-DnsServerZone and Get-DnsServerResourceRecord before changing forwarders, aging or scavenging.

Getting it

Available on any DNS server, and on an admin workstation once the RSAT DNS tools are installed with Add-WindowsCapability -Online -Name Rsat.Dns.Tools.

Examples

1PS> Get-DnsServerZone -ComputerName DC01
Show reference output
1 ZoneName ZoneType IsDsIntegrated IsReverseLookupZone
2 -------- -------- -------------- -------------------
3 corp.local Primary True False
1PS> Get-DnsServerForwarder -ComputerName DC01
Show reference output
1 IPAddress UseRootHint Timeout(s)
2 --------- ----------- ----------
3 1.1.1.1 True 5
4 8.8.8.8 True 5

What it is for

Use it when the job is to change or audit what a DNS server holds rather than to resolve a name. It fits zone inventories, stale record cleanup, and confirming that conditional forwarders point where the design says they should.

Typical tasks

  • Inventory forward and reverse lookup zones
  • Export A and CNAME records for a zone
  • Audit forwarders and root hints
  • Check aging and scavenging settings
  • Add or remove a record during a cutover
  • Compare zone contents between two servers

Check the installed version

1PS> Get-Module -ListAvailable DnsServer | Select-Object Name, Version, Path
2PS> Get-Command -Module DnsServer

Compare the module path and version with the session used by your scheduled task or automation account. Use it when the job is to change or audit what a DNS server holds rather than to resolve a name. It fits zone inventories, stale record cleanup, and confirming that conditional forwarders point where the design says they should.

Primary documentation

PowerShell objects and pipelines documentation

Continue
Genie guideDnsServer module: setup and commands

Query DNS zones and records with Get-DnsServerZone and Get-DnsServerResourceRecord before changing forwarders, aging or scavenging.