How to Manage Windows Server 2016 DNS Server Using PowerShell

How to Manage Windows Server 2016 DNS Server Using PowerShell

In this blog post, I’ll show you How to Manage Windows Server 2016 DNS Server Using PowerShell, without using the DNS Console or any other GUI Interface.

With the rising popularity of Windows Server Core, Nano Server And Docker GUI Interfaces on that platform are available and In some cases, you need to use a management machine to manage your DNS Server.

How to set or change IP configuration using a powershell script

By knowing how to manage Windows DNS Server using PowerShell you could save yourself precious time and just use the module.

The Windows DNS Module was first released back with Windows Server 2008 R2 with 40% of the tasks available to do using the module, With the release of Windows Server 2016, you could fully your DNS Server using the module without the GUI.

How to use Best Practices Analyzer in Windows Server 2012 R2

By default, the GUI Is available with the Installation of the DNS Server role.

Managing Windows Server 2016 DNS Server Using PowerShell :

To get started and view all the available cmdlets simply open PowerShell and run the cmdlet below.

Get-Command -Module dnsserver
How to Manage Windows Server 2016 DNS Server Using PowerShell
How to Manage Windows Server 2016 DNS Server Using PowerShell

As you could see below, the module has 134 cmdlets available

How to Manage Windows Server 2016 DNS Server Using PowerShell
How to Manage Windows Server 2016 DNS Server Using PowerShell

Below, I’ll create a new Primary Zone called devtest.local

Add-DnsServerPrimaryZone -Name devtest.local -ZoneFile devtest.dns

To view all available zone, I’ll run the cmdlet below

Get-DnsServerZone

To create a reserve DNS Lockup zone, I’ll use the cmdlet below

Add-DnsServerPrimaryZone -NetworkId "172.23.106.0/24" -ReplicationScope Domain

To add an A Record DNS entry to my new zone I’ll use

add-DnsServerResourceRecordA -Name host1.devtest.local -IPv4Address 192.168.100.30 -ZoneName devtest.local

To sync my Zone to other DNS Server I’ll use the line below

Sync-DnsServerZone -PassThru

To test my DNS Server against an IP address I’ll use the cmdlet below

Test-DnsServer

Related Articles:

How to Install Windows Server 2016 Domain Controller Using PowerShell

 

  • Jim

    Hi Guys,

    I need to migrate DNS server from Windows 2012 R2 to Windows 2016. Copying settings between Windows 2012 R2 systems works fine (using PS)
    PS C:> Get-DnsServer -ComputerName “DNSServer13.Contoso.com” | Export-Clixml -Path “c:DnsServerConfig.xml”
    PS C:> $x = Import-Clixml “c:DnsServerConfig.xml”
    PS C:> Set-DnsServer -InputObject $x -ComputerName “DNSServer22.Contoso.com”

    On Windows 2016 I receive below error:
    Set-DnsServer : Not found
    At line:1 char:1
    + Set-DnsServer -InputObject $x -ComputerName “DNSServer22.Contos…
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (PS_DnsServer:root/Microsoft/Windows/DNS/PS_DnsServer) [Set-DnsServer],
    CimException
    + FullyQualifiedErrorId : HRESULT 0x80041002,Set-DnsServer

    Both systems in the same AD.

    Thanks in advance
    Best regards
    Jim

Search








Bitnami