導出DNS服務器上的記錄


近日遇到一個需求,需要將DNS服務器上的所有記錄都導出。

試了一下,如果從DNS管理單元里直接選擇導出列表,那么子域的DNS記錄是不會被導出的。這樣顯然不行,需要尋找其它方法。本來想用Export-DnsServerZone,但是發現它只能導出本機上的DNS記錄。因為平時的管理都只是在管理機上,輕易不會去登錄DNS服務器的,所以最好能找到其它的命令。經過搜索,找到后面這些命令。

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

這些命令導出的文件會包含條件轉發器的區域,但是條件轉發器區域對應的文件是空的。

從DNS服務器

$Zones = @(Get-DnsServerZone)

ForEach ($Zone in $Zones) {

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

$Zone | Get-DnsServerResourceRecord

}

從其它DNS服務器

$DNSServer = "servernameOrIp"

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

ForEach ($Zone in $Zones) {

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

$Zone | Get-DnsServerResourceRecord -ComputerName $DNSServer

}

從其它DNS服務器,輸出table分隔的文件

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

}

 

原帖地址

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM