Public/Remove-NameServerFromDNSReverseZones.ps1
Function Remove-NameServerFromDNSReverseZones { param( [Parameter(Mandatory)][string]$NameServerToRemove ) $PDCE = Get-ADDomainController -Discover -Service PrimaryDC $AllZones = Get-DnsServer -ComputerName $PDCE | Select-Object -Property serverzone -ExpandProperty serverzone | Where-Object { $_.isdsintegrated -eq "true" -and $_.isreverselookupzone -eq "true" } | Select-Object -Property zonename ForEach ($Zone in $AllZones) { $NameServers = Get-DnsServerResourceRecord -ComputerName $PDCE -ZoneName $zone.zonename -RRType "NS" If ($NameServers.RecordData.NameServer -match $NameServerToRemove) { Remove-DnsServerResourceRecord -ComputerName $PDCE -ZoneName $zone.zonename -RRType Ns -Name "@" -RecordData $NameServerToRemove -Force } } } |