---
title: "PowerShell DNS Zone Management Made Easy"
description: "Save time and effort by using PowerShell to add and manage DNS zones in this step-by-step tutorial."
canonical: "https://adamtheautomator.com/powershell-add-dns-zone/"
---

# PowerShell DNS Zone Management Made Easy

> Save time and effort by using PowerShell to add and manage DNS zones in this step-by-step tutorial.

Source: https://adamtheautomator.com/powershell-add-dns-zone/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![PowerShell DNS Zone Management Made Easy](https://adamtheautomator.com/wp-content/uploads/2019/07/dns-1-.jpg)

# PowerShell DNS Zone Management Made Easy

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)1 July 20193 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Microsoft DNS](/tag/microsoft-dns/)[PowerShell](/tag/powershell/)

Table of Contents

*   [Prerequisites](#h-prerequisites)
*   [Verifying the DNSServer Module](#h-verifying-the-dnsserver-module)
*   [Using PowerShell to Add a DNS Zone](#h-using-powershell-to-add-a-dns-zone)
*   [Verifying the DNS Zone Creation](#h-verifying-the-dns-zone-creation)
*   [Removing the DNS Zone with PowerShell](#h-removing-the-dns-zone-with-powershell)
*   [Summary](#summary)

If you find yourself making changes on your Microsoft DNS servers using the DNS MMC snap-in you’re probably wasting a lot of time. Learn how to use PowerShell to add DNS zones and manage them entirely!

Not a reader? Watch this related video tutorial!

**_Not seeing the video? Make sure your ad blocker is disabled._**

Why? Because it’s possible to create, modify or remove any DNS object that you can from the MMC with PowerShell! By using PowerShell to [manage DNS](https://www.ipswitch.com/resources/free-tools/best-practices-for-application-performance-monitoring-toolkit?c_id=7011A000001QUbfQAG&details=Blog) allows you not only to control things from the command line but to take those commands and put them into a script to automate all kinds of time-consuming tasks.

To limit this article’s scope, we’re going to just focus on [managing DNS zones with PowerShell](https://adamtheautomator.com/powershell-scheduled-task/) although it’s completely possible to administer other DNS objects like records and the server itself as well.

## Prerequisites

Before we get too far, there are a few prerequisites you need to be aware of. First, I’m assuming you have permission to read, modify, and remove DNS zones using PowerShell from your Windows servers.

Second, I’ll be demonstrating a few concepts from DNS servers that are in an Active Directory domain with AD-integrated zones. PowerShell is still capable of managing zones and records outside of Active Directory but may not quite be the same result as I’ll be showing you here.

Finally, you’ll need to ensure you have a version of the Remote Server Administration Tools (RSAT) installed on your client-specific to your operating system.

**_Related: [How to Install the Active Directory Module and Connect](https://adamtheautomator.com/powershell-import-active-directory/)_**

## Verifying the DNSServer Module

Now that we have that out of the way let’s start out by first ensuring the _DNSServer_ module is available to us. To do that, I’ll use the `Get-Module` cmdlet.

```powershell
PS> Get-Module DnsServer -ListAvailable
 
 
     Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules
 
 
 ModuleType Version    Name                                ExportedCommands
 ---------- -------    ----                                ----------------
 Manifest   2.0.0.0    DnsServer                           {Add-DnsServerConditionalForwarderZone, Add-DnsServerDirectoryPartition, Add-DnsServerForwarder, Add-DnsServerPrimaryZone...}
 
Great! It looks like our module is downloaded and we have some available commands. Let's now see what commands we have to work with DNS zones.
 
PS> Get-Command -Module DnsServer -Noun *Zone*
 
 CommandType     Name                                               Version    Source
 -----------     ----                                               -------    ------
 Function        Add-DnsServerConditionalForwarderZone              2.0.0.0    DnsServer
 Function        Add-DnsServerPrimaryZone                           2.0.0.0    DnsServer
 -- SNIP --
```

## Using PowerShell to Add a DNS Zone

First up, let’s create a zone with PowerShell. To do this, we’ll use the `Add-DnsServerPrimaryZone` function. The simplest way this can be done is by using two parameters. Those parameters are `Name` and `ReplicationScope`. However, in our example, I’ll also be using the `ComputerName` parameter since I’m invoking this command on a remote computer.

```powershell
PS> Add-DnsServerPrimaryZone -Name testzone.mylab.local -ComputerName DC -ReplicationScope Forest
```

Above you can see that my domain is mylab.local and my zone name is testzone. My DNS server is DC so I’m specifying that for the `ComputerName` parameter and finally since this server is on my domain I have to also set the `ReplicationScope` so I’ve chosen to replicate this zone amongst all other [DNS servers in my Active Directory forest](https://www.ipswitch.com/resources/free-tools/whatsup-active-directory-monitor?c_id=7011A000001QUbfQAG&details=Blog).

## Verifying the DNS Zone Creation

Next, to verify this zone was created, I can then use the `Get-DnsServerZone` command. I could use the `Name` parameter but to show you all of the zones I have I’ll just tell `Get-DnsServerZone` to find all of them.

```powershell
PS> Get-DnsServerZone -ComputerName DC
 
 ZoneName                            ZoneType        IsAutoCreated   IsDsIntegrated  IsReverseLookupZone  IsSigned
 --------                            --------        -------------   --------------  -------------------  --------
 _msdcs.mylab.local                  Primary         False           True            False                False
 0.in-addr.arpa                      Primary         True            False           True                 False
 127.in-addr.arpa                    Primary         True            False           True                 False
 255.in-addr.arpa                    Primary         True            False           True                 False
 mylab.local                         Primary         False           True            False                False
 testzone.mylab.local                Primary         False           True            False                False
 TrustAnchors                        Primary         False           True            False                F
```

## Removing the DNS Zone with PowerShell

And just to be sure we go through the entire lifecycle of a DNS zone, I’ll then remove it.

```powershell
PS> Remove-DnsServerZone -Name testzone.mylab.local -ComputerName DC -Confirm
```

This will also remove all the records in the zone, and the server will no longer host the zone, do you want to continue?

```powershell
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
 PS>  Get-DnsServerZone -ComputerName DC
 
 ZoneName                            ZoneType        IsAutoCreated   IsDsIntegrated  IsReverseLookupZone  IsSigned
 --------                            --------        -------------   --------------  -------------------  --------
 _msdcs.mylab.local                  Primary         False           True            False                False
 0.in-addr.arpa                      Primary         True            False           True                 False
 127.in-addr.arpa                    Primary         True            False           True                 False
 255.in-addr.arpa                    Primary         True            False           True                 False
 mylab.local                         Primary         False           True            False                False
 TrustAnchors                        Primary         False           True            False      
```

Now that you’ve learned about DNS zone, why not pick up at the next logical spot and begin learning about DNS records in this [detailed, step-by-step, tutorial on managing DNS records](https://adamtheautomator.com/powershell-dns/).

## Summary

There is so much more possible with managing DNS zones in PowerShell. I encourage you to look through all of the commands possible in `Get-Command -Module DnsServer -Noun Zone`. This command gives you a list of all of the commands inside of the _DnsServer_ module that have ‘_Zone_‘ in the name. You’ll find that the command names are self-explanatory and if you need to investigate further always consult the help of each command using [`Get-Help`](https://adamtheautomator.com/powershell-get-help/ "Get-Help").

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-add-dns-zone%2F&text=PowerShell%20DNS%20Zone%20Management%20Made%20Easy)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-add-dns-zone%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-add-dns-zone%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2020/03/resolve-dns-name.jpg)

### [Resolve-DnsName: Master DNS Record Lookup in PowerShell](/resolve-dnsname/)

Master the Resolve-DnsName cmdlet for DNS record lookup in PowerShell. Learn the differences from other tools and enhance your IT skills.

![](https://adamtheautomator.com/wp-content/uploads/2019/07/photo-1542221947260-bfa41adbce43.jpg)

### [Automate DNS Tasks with PowerShell DNS Cmdlets](/powershell-dns/)

Streamline your DNS management using PowerShell DNS cmdlets and say goodbye to tedious tasks.

![](https://adamtheautomator.com/wp-content/uploads/2019/07/tracking-iterative-public-dns-queries-dns.png)

### [WireShark DNS Filtering: A PowerShell Setup Guide](/wireshark-dns-filter/)

Setup WireShark DNS filters like a pro. Step-by-step guide on tracking down Iterative DNS queries.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
