Configure Conditional Forwarders with PowerShell – Windows Server Core 2016

This is a guide for adding and removing conditional forwarders in DNS using PowerShell. To do this with DNS Manager, please see Configure Conditional Forwarders – Windows Server 2016.

How-To

Prerequisites

Before starting, you will need the DNS role installed. If you have not done this, you can use one of the following articles:

For Server Core 2016 or Server 2016 with Desktop Experience

Installing the DNS Role with PowerShell -Windows Server Core 2016

For Server 2016 with Desktop Experience

Installing the DNS Role using Server Manager – Windows Server 2016

 

Open PowerShell
1a) Open Command Prompt (cmd) as an Administrator and start PowerShell

If you are on Server Core this is likely already open. If it is not, hold Ctrl+Alt+Del and select Task Manager. Then choose File -> Run new task, type cmd, select Run with administrative privileges and click OK or hit Enter.

Type the word PowerShell and hit Enter

1b) Open PowerShell as an Administrator

If using Server 2016 with the desktop experience, you can simply open PowerShell as an admin

Start typing PowerShell in the Start Menu and then right-click Windows PowerShell and select Run as administrator

Add a Forwarder
1) Check the current zones

Type Get-DnsServerZone and hit Enter

This will display any DNS zones that have already been added

Conditional forwarders have a zone type of “Forwarder”, there are none in the example below

2) Add a conditional forwarder

Type Add-DnsServerConditonalForwarderZone -Name NameOfZoneHere -MasterServers ForwarderServerAddressesHere and hit Enter

3) Confirm the conditional forwarder was added

If there was no error message when running the command above, then the conditional forwarder was added successfully

To confirm, type Get-DnsServerZone and hit Enter

This will should display the DNS zones again, with your new forwarder zone included

Remove a Conditional Forwarder
1) Check the current forwarders

Type Get-DnsServerZone to see the current forwarders (see above)

2) Remove a conditonal forwarder

Type Remove-DnsServerZone -Name NameOfZoneHere and hit Enter

Type Y and hit Enter to confirm

3) Confirm the conditional forwarder was removed

If there was no error message when running the command above, then the forwarder was removed successfully

To confirm, type Get-DnsServerZone and hit Enter

This will should display the DNS zones again, with your conditional forwarder removed