Powershell İle Dns Zone Kayıtlarını Export Etmek Çözüm İçerde!

Merhaba, aşağıdaki powershell kodu ile tüm dns zone ve altındaki kayıtları csv olarak export edebilirsiniz.

import-module DNSServer
$DNSReport = 
foreach($record in Get-DnsServerZone){
    $DNSInfo = Get-DnsServerResourceRecord $record.zoneName
    foreach($info in $DNSInfo){
        [pscustomobject]@{
            ZoneName   = $record.zoneName
            HostName   = $info.hostname
            TimeStamp  = $info.timestamp
            RecordType = $info.recordtype
            RecordData = if($info.RecordData.IPv4Address){
                             $info.RecordData.IPv4Address.IPAddressToString}
                         else{
                             try{$info.RecordData.NameServer.ToUpper()}catch{}
                         }
        }
    }
}
$DNSReport |
Export-Csv "DNSRecords.csv" -NoTypeInformation