Remove a Name Server from All Reverse Zones

##############################

# The following section contains all input parameters

$DC = “DC1.contoso.internal” # Domain controller to be used

$nameserver = “DNS.contoso.internal” # Nameserver to remove

#

##############################

$list = Get-DnsServer -ComputerName $DC | select -Property serverzone -ExpandProperty serverzone | where  {$_.isdsintegrated -eq “true” -and $_.isreverselookupzone -eq “true”} | select -Property zonename

foreach ($zone in $list ) {Remove-DnsServerResourceRecord -ComputerName $DC -ZoneName $zone.zonename -RRType Ns -Name “@” -RecordData $nameserver -Force}

Get all DNS Zones and Records in CSV

$results = Get-DnsServerZone | % {

    $zone = $_.zonename

    Get-DnsServerResourceRecord $zone | select @{n=’ZoneName’;e={$zone}}, HostName, RecordType, @{n=’RecordData’;e={if ($_.RecordData.IPv4Address.IPAddressToString) {$_.RecordData.IPv4Address.IPAddressToString} else {$_.RecordData.NameServer.ToUpper()}}}

}

$results | Export-Csv -NoTypeInformation c:\temp\DNSRecords.csv -Append

Exit mobile version
%%footer%%