Export record on the DNS server

Recently met a demand, require that all records on the DNS server are exported.

Tried it, if you choose to export the list directly from the DNS snap-in, then the DNS records for the subdomain will not be exported. This is clearly not, need to find other methods. I had wanted to use Export-DnsServerZone, but found that it can only export a DNS record on the unit. Because the usual management are just on the management machine, will not easily log on to the DNS server, so it is best to find other commands. After a search, found the back of these commands.

 https://www.cnblogs.com/qishine/p/12375825.html

These commands are exported file will contain the region conditional forwarder, but conditional forwarder region corresponding file is empty.

From the DNS server

$Zones = @(Get-DnsServerZone)

ForEach ($Zone in $Zones) {

Write-Host "`n$($Zone.ZoneName)" -ForegroundColor "Green"

$Zone | Get-DnsServerResourceRecord

}

From other DNS servers

$DNSServer = "servernameOrIp"

$Zones = @(Get-DnsServerZone -ComputerName $DNSServer)

ForEach ($Zone in $Zones) {

Write-Host "`n$($Zone.ZoneName)" -ForegroundColor "Green"

$Zone | Get-DnsServerResourceRecord -ComputerName $DNSServer

}

From another DNS server, the output of table-delimited file

$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"

}

 

The original post address

http://sigkillit.com/2015/10/27/list-all-dns-records-with-powershell/

Guess you like

Origin www.cnblogs.com/qishine/p/12375825.html