How to Create a New DNS Zone in Windows Server using PowerShell

Automating DNS Infrastructure

In a Windows Server environment, the Domain Name System (DNS) is the critical infrastructure that translates human-readable domain names (like intranet.contoso.local) into IP addresses. When a company acquires a new subsidiary, or spins up a massive isolated development environment, system administrators must create new DNS Zones to handle the traffic for those new domains.

While you can log into the server via Remote Desktop and use the graphical DNS Manager (dnsmgmt.msc) to click through the “New Zone Wizard,” this is inefficient if you are spinning up 20 different development zones. PowerShell allows you to create fully functional DNS zones instantly from the command line.

Using the Add-DnsServerPrimaryZone Cmdlet

To execute this command, you must run PowerShell as an Administrator on a Windows Server that has the DNS Server role installed (or on a workstation with the RSAT DNS tools installed).

To create a standard, standalone Primary DNS Zone for a new domain named dev.local, use the Add-DnsServerPrimaryZone cmdlet.

Add-DnsServerPrimaryZone -Name "dev.local" -ZoneFile "dev.local.dns"

Breaking Down the Parameters:

  • -Name: The actual domain name of the zone you are creating.
  • -ZoneFile: Because this is a standard primary zone (not integrated into Active Directory), you must tell Windows what to name the physical text file that will store the DNS records. By default, this file is created in C:\Windows\System32\dns\.

Creating an Active Directory Integrated Zone

In 99% of enterprise Windows environments, you do not want a standalone text file zone. You want an Active Directory Integrated Zone. This allows the DNS records to securely replicate across every Domain Controller in your network automatically.

To create an AD-integrated zone, you drop the -ZoneFile parameter and append the -ReplicationScope parameter instead.

Add-DnsServerPrimaryZone -Name "secure.contoso.local" -ReplicationScope Domain

By setting the scope to Domain, Windows automatically stores the DNS zone deep within the Active Directory database and immediately begins replicating it to all other Domain Controllers in the contoso.local domain.

Enabling Dynamic Updates

If you create a zone for a new subnet of employee laptops, you do not want to manually create a DNS record every time a laptop connects to the Wi-Fi. You want the laptops to automatically register their own IP addresses in the zone.

You can enable Secure Dynamic Updates during the creation process by appending the -DynamicUpdate flag.

Add-DnsServerPrimaryZone -Name "wifi.contoso.local" -ReplicationScope Domain -DynamicUpdate Secure

The command executes silently. If you open the graphical DNS Manager, you will instantly see the new wifi.contoso.local folder, fully configured, securely replicated via Active Directory, and ready to accept automatic IP registrations from your domain-joined workstations.

Get the best tech tips delivered straight to your inbox.

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