The below PS script exports the conditional forwarders and their master server ip addresses
gwmi -Namespace root\MicrosoftDNS -Class MicrosoftDNS_Zone -Filter "ZoneType = 4" |
Select -Property @{n='Name';e={$_.ContainerName}}, @{n='DsIntegrated';e={$_.DsIntegrated}}, @{n='MasterServers';e={([string]::Join(',', $_.MasterServers))}}, @{n='AllowUpdate';e={$_.AllowUpdate}} | Export-Csv "condForwarders.csv"
The below command reads a txt file for the conditional forwarder names and for each name it creates a AD integrated conditional forwarder. The master server ip can be read from txt or hardcoded lke I do in this example.
Import-Csv "c:\arecords.txt" |
foreach{Add-DnsServerConditionalForwarderZone -Name $_.name -ReplicationScope "Forest" -MasterServers 172.10.10.200}
arecords.txt content can be something like this:
name
test1.com
test2.com
test3.com
test1.net
test1.biz
############
You can use the below command to remove the existing Conditional Forwarders by using the csv content
Import-Csv "c:\arecords.txt" |
foreach{ Remove-DnsServerZone -Name $_.name -Force -Confirm:$false }