Public/Remove-NameServerFromDNSForwardZones.ps1
Function Remove-NameServerFromDNSForwardZones { 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 "false" } | Select-Object -Property zonename $AllZones | ForEach-Object { Try { $_ | Remove-DnsServerResourceRecord –Name “@” –RRType NS –RecordData $NameServerToRemove -ComputerName $PDCE -Force } Catch { [System.Exception] "Something went wrong..." } } } |