none
Export-DNSServerZone -FileName does not work RRS feed

  • Question

  • 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

    Monday, March 5, 2018 9:41 PM

Answers

All replies

  • I found it under DNS when using no path.  What the heck?  It's 2018 Microsoft!

    David Jenkins

    Monday, March 5, 2018 9:44 PM
  • 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 tnmff@microsoft.com

    Tuesday, March 6, 2018 8:18 AM
  • 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

    Monday, May 7, 2018 7:59 PM
  • 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 tnmff@microsoft.com

    Tuesday, May 8, 2018 3:13 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.

    Monday, May 27, 2019 6:39 AM
  • Just realised by DNS, you mean: C:\Windows\System32\dns

    Found them at last! 

    Wednesday, June 5, 2019 10:36 AM