Solved

Backing Up a Primary DNS Server with PowerShell

Posted on 2013-06-28
6
2,631 Views
Last Modified: 2013-07-05
I'm attempting to backup a primary, non-Active Directory, DNS server with PowerShell. It's a Windows Server 2012 Standard server with all of the updates applied, and only the DNS role installed.  I found the code from this TechNet example.

#Get DNS Server configuration and store it in ServerConfig.xml 
Get-DnsServer | Export-Clixml -Path ServerConfig.xml 

Open in new window


This part worked great, and spit everything out into an XML file. I ran through the file, and verified that all of the forward lookup zones, reverse lookup zones, and conditional forwarder zones were there.

I attempted to restore the XML configuration to another Windows Server 2012 Standard server with the DNS role installed using the restore command.

#Import the configuration from ServerConfig.xml and set it on TargetServer through CimSession 
Import-Clixml -Path ServerConfig.xml | Set-DnsServer –CimSession TargetServer

Open in new window


The problem is only the conditional forwarder zones were restored. The forward lookup zones and reverse lookup zones didn't transfer.

Is there something I'm missing?
0
Comment
Question by:mattheweharding
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 15

Expert Comment

by:Rob Stone
ID: 39285701
It's stating that it is only backing up the server configuration, not the zone's.

This link has a PS script to backup the DNS zones:
http://c-nergy.be/blog/?p=1837

Restore DNS zones:
http://c-nergy.be/blog/?p=1858

If you just want to copy the zone's over, you can take a copy of the DNS file in %systemroot%\system32\dns and copy that to the other DNS server.
0
 

Author Comment

by:mattheweharding
ID: 39285708
I've tried that script on Server 2012, and didn't work.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39286084
See example 1 from following article..
http://technet.microsoft.com/en-us/library/jj649845.aspx
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Author Comment

by:mattheweharding
ID: 39290005
Same problem with that script. Only the conditional forwarders are created. Not the forward and reverse lookup zones.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39300817
Are you getting ay warning or Error?
0
 
LVL 15

Accepted Solution

by:
Rob Stone earned 500 total points
ID: 39301543
This also works, although it's a bit cumbersome:

Exported a zone using the following cmdlet
Export-DnsServerZone -Name zonename.local -FileName ZonenameExport.local.dns

This exported the file to C:\Windows\System32\DNS.

I then copied the file to another DNS server, renamed it to Zonename.local.dns and ran the following command:
DNSCMD /ZoneAdd Zonename.local /Primary /File Zonename.local.dns /load

This then loaded the zone and records into DNS.
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
In this Micro Tutorial viewers will learn how to restore single file or folder from Bare Metal backup image of their system. Tutorial shows how to restore files and folders from system backup. Often it is not needed to restore entire system when onl…
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question