Remove DNS NS Records after demoting domain controller with PowerShell

  Get-DnsServerZone | ForEach-Object { Get-DnsServerResourceRecord -ZoneName $_.ZoneName -RRType Ns | Where-Object {$_.RecordData.NameServer -like ‘DCName.fqdn.com.‘} | Remove-DnsServerResourceRecord -ZoneName $_.ZoneName -Confirm:$false }   Replace the bold test with the fully qualified domain name of the name server. Don’t forget to keep the period at the end of it as well.