How to Export a List of All Active DNS Zones using PowerShell

Managing Windows Server DNS

In a large enterprise environment, the Windows Server DNS (Domain Name System) role might host dozens or hundreds of different forward lookup zones for internal applications, dev environments, and external domain names. Over time, administrators might create a zone for a temporary project, forget about it, and leave it running for years.

To audit your DNS infrastructure, you need a clean, readable list of every single zone currently hosted on the server, along with its status (Active or Paused) and its type (Primary, Secondary, or Stub). While you can click through the DNS Manager GUI, using PowerShell allows you to export this data directly to a CSV file for analysis.

Step 1: Install the DNS Server Module

To run these commands, you must execute them directly on the DNS Server, or on an IT workstation that has the RSAT (Remote Server Administration Tools) for DNS installed. The required cmdlets are part of the DnsServer module.

Open an elevated PowerShell prompt (Run as Administrator) and run:

Import-Module DnsServer

Step 2: Retrieving All DNS Zones

The core cmdlet to retrieve zone information is Get-DnsServerZone. If you run this command without any parameters, it will output a massive list of every zone on the server, including the built-in Active Directory reverse lookup zones and TrustAnchors.

Get-DnsServerZone

Step 3: Filtering the Output

For a clean audit report, you generally only want the name of the zone, its type, and whether it is currently active. You can pipe the results into the Select-Object cmdlet to isolate these specific properties.

Get-DnsServerZone | Select-Object ZoneName, ZoneType, IsPaused, IsAutoCreated

You can take this a step further by filtering out the auto-created system zones (like _msdcs.yourdomain.com), leaving you with only the custom zones created by administrators.

Get-DnsServerZone | Where-Object { $_.IsAutoCreated -eq $false } | Select-Object ZoneName, ZoneType

Step 4: Exporting to CSV

Once you have the data perfectly filtered in the terminal, you can easily export it to a spreadsheet to share with your network engineering team.

Append the Export-Csv cmdlet to the end of your pipeline:

Get-DnsServerZone | Where-Object { $_.IsAutoCreated -eq $false } | Select-Object ZoneName, ZoneType | Export-Csv -Path "C:\Temp\DNSZones.csv" -NoTypeInformation

Navigate to C:\Temp\ and open the DNSZones.csv file in Excel. You will have a clean, perfectly formatted audit report of your entire DNS infrastructure.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.