Silly question, but did you run this as an admin since the system32 folder doesn’t allow non-admins to write to it by default? Perhaps as a test write to an open area in your profile perhaps.
Also, do the folders dns and backup exist? If not, create them first and then re-try running it. -Aakash Shah -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Michael Leone Sent: Friday, August 14, 2015 9:13 AM To: [email protected] Subject: Re: [powershell] Backing up DNS The Export-DnsServerZone doesn't seem to like accepting a variables: (not running this script on the actual DC, I am running it from another Win2012 R2 server, and pointing it at a DC) ------------------------------------- $DNSServer = Get-DnsServer -ComputerName <servername> $AllZones = $DNSServer.ServerZone ForEach ($Zone in $AllZones) { IF ($Zone.IsReverseLookupZone) { $MyZone = $Zone.ZoneName $MyZoneFileName = "c:\windows\system32\dns\backup\" + $Zone.ZoneName + ".TXT" Export-DnsServerZone -ComputerName <servername> -Name $MyZone -Filename $MyZoneFileName } } ------------------------------------ Export-DnsServerZone : Failed to export the zone content for 0.in-addr.arpa on server <servername> to the file c:\windows\system32\dns\backup\0.in-addr.arpa.TXT. At P:\software\PHA Scripts\AD related scripts\Save-all-DNS-zones-and-records.PS1:17 char:3 + Export-DnsServerZone -ComputerName <servername> -Name $MyZ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (0.in-addr.arpa:root/Microsoft/...S_DnsServerZone) [Export-DnsServerZone], CimException + FullyQualifiedErrorId : WIN32 9611,Export-DnsServerZone So what's up with that? What is wrong here? I saw posts about using "..\..\..\" as relative path in the export filename, but that doesn't work either. Am I just missing something simple? ================================================ Did you know you can also post and find answers on PowerShell in the forums? http://www.myitforum.com/forums/default.asp?catApp=1 ================================================ Did you know you can also post and find answers on PowerShell in the forums? http://www.myitforum.com/forums/default.asp?catApp=1
