Exporting DNS console to .CSV file using PowerShell or any means necessary?

Welcome Forums General PowerShell Q&A Exporting DNS console to .CSV file using PowerShell or any means necessary?

This topic contains 5 replies, has 4 voices, and was last updated by

 
Participant
1 month, 2 weeks ago.

  • Author
    Posts
  • #119599

    Participant
    Points: 65
    Rank: Member

    Hi All,

    Using Windows Server 2012 R2 and Windows Server 2012 DNS console or PowerShell,

    I need to export the list of DNS forward lookup zones and also the Conditional forwarders in my DNS Management console to .CSV so I can compare it between two DNS server in different AD domains.

    Any help and suggestion would be greatly appreciated.

     

    Thank in advance.

  • #119608

    Participant
    Points: 268
    Helping Hand
    Rank: Contributor

    Hmmm ... have you already searched for it?

    https://docs.microsoft.com/en-us/powershell/module/dnsserver/get-dnsserver?view=win10-ps

    What help do you expect/need?

  • #119625

    Participant
    Points: 65
    Rank: Member

    When I execute the below script:

    $DNSServer = "servernameOrIp"
    $Zones = @(Get-DnsServerZone -ComputerName $DNSServer)
    ForEach ($Zone in $Zones) {
    Write-Host "`n$($Zone.ZoneName)" -ForegroundColor "Green"
    $Results = $Zone | Get-DnsServerResourceRecord -ComputerName $DNSServer
    echo $Results > "$($Zone.ZoneName).txt"
    }

    I get the error:

    Get-DnsServerZone : The term 'Get-DnsServerZone' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:2 char:12
    + $Zones = @(Get-DnsServerZone -ComputerName $DNSServer)
    + ~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Get-DnsServerZone:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

     

  • #119676

    Moderator
    Points: 103
    Team MemberHelping Hand
    Rank: Participant

    Have you installed the DNSServer PowerShell module on your local machine (or the machine you're running the command on)?

    It it likely to be in the Windows RSAT, if you haven't.

  • #119685

    Participant
    Points: 889
    Helping Hand
    Rank: Major Contributor

    DNSServer module comes when the feature is enabled, make sure its enabled otherwise, as mentioned above you can make use of RSAT or you can use implicit remoting as well.

  • #119872

    Participant
    Points: 65
    Rank: Member

    OK, It seems the remoting is working great for me.

    Thanks all for the sharing and the solutions.

You must be logged in to reply to this topic.