Configure DNS Forwarders with PowerShell – Windows Server Core 2016

This guide shows you how to add and remove DNS Forwarders using PowerShell. To do this using DNS Manager, please see Configure DNS 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 forwarders

Type Get-DnsServerForwarder and hit Enter 

This will display any DNS forwarders that have already been added

2) Add a forwarder

Type Add-DnsServerForwarder -IPAddress IpAddressHere and hit Enter

3) Confirm the forwarder was added

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

To confirm, type Get-DnsServerForwarder and hit Enter 

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

Remove a Forwarder
1) Check the current forwarders

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

2) Remove a forwarder

Type Remove-DnsServerForwarder -IPAddress IpAddressHere and hit Enter

Type Y and hit Enter to confirm

3) Confirm the forwarder was removed

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

To confirm, type Get-DnsServerForwarder and hit Enter 

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

Leave a Reply

Your email address will not be published. Required fields are marked *