Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, March 5, 2018 9:41 PM
Why do I get an error trying to export a zone using powershell? I see many users complaining but no resolution?
Export-DNSServerZone -name lab.local -filepath "C:\folder\path\file.name"
If I just give a filename it produces no error but no file either.
David Jenkins
All replies (8)
Monday, March 5, 2018 9:44 PM ✅Answered
I found it under DNS when using no path. What the heck? It's 2018 Microsoft!
David Jenkins
Monday, February 17, 2020 3:41 PM ✅Answered
I hadn't touched this command in a while. Ended up finding this thread when I had the issue.
Here's a nice backup one line.
Get-DnsServerZone | where{$_.ZoneType -eq "Primary" -and $_.IsReverseLookupZone -eq $false} | %{Remove-Item -ErrorAction SilentlyContinue -LiteralPath "..\..\..\Scripts\dnsexports\$($_.ZoneName).bak";Export-DnsServerZone -Name $_.ZoneName -FileName "..\..\..\Scripts\dnsexports\$($_.ZoneName).bak"}
David Jenkins
Tuesday, March 6, 2018 8:18 AM
Hi David,
Thanks for your question.
Good to hear that you have solved this issue by yourself. In addition, thanks for sharing your solution in the forum as it would be helpful to anyone who encounters similar issues.
If there is anything else we can do for you, please feel free to post in the forum.
Wish you have a nice day!
Best regards,
Michael
Please remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]
Monday, May 7, 2018 7:59 PM
The FileName parameter does not work as the documentation describes.
-FileName<String>
"Specifies a name for the export file. You can include a file path."
Specifying a full file path does NOT work. You will get an exception unless you use only a file name or a relative path (Which is relative to the dns folder - ie ../../../file.name will write 'file.name' to the root of your system drive)
The cmdlet documentation should be updated to reflect this reality or the cmdlet updated to work as described.
BC
Tuesday, May 8, 2018 3:13 AM
Yes! You're right.
More detailed information about this issue, you may follow this thread,
http://www.wolffhaven45.com/uncategorized/export-dnsserverzone-fails-to-export/
Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
Best regards,
Michael
Please remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]
Monday, May 27, 2019 6:39 AM
This is how ist works for me.
$Zones = (Get-DnsServerZone | Where-Object IsReverseLookupZone -eq $False).ZoneName
foreach ($line in $Zones)
{
Write-Host "`n $Line" -ForegroundColor "Green"
Export-DnsServerZone -Name $Line -FileName "$Date-${line}.dns"
}
Putting the variable in {} will do the trick.
Important is to run the script in the Administrator context.
Wednesday, June 5, 2019 10:36 AM | 1 vote
Just realised by DNS, you mean: C:\Windows\System32\dns
Found them at last!
Wednesday, January 22, 2020 9:21 PM
well gosh, thank heavens they gave us a handy -computername parameter so we can run this cmdlet remotely instead of locally on the DNS server when the export can only be saved locally on the DNS server.