I put the name and IP address of the conditional forwarder in the CSV file, how can I delete the conditional forwarder of DNS through the records in the file?
I put the name and IP address of the conditional forwarder in the CSV file, how can I delete the conditional forwarder of DNS through the records in the file?
Hi,
Sorry for the misunderstanding above. Yes the Remove-DnsServerZone cmdlet removes a conditional forwarder from the DNS server. It accepts the zone name as a parameter.
Import-Csv -Path $file | ForEach-Object {
Remove-DnsServerZone -Name $_.name -Force
}
Please refer to this link for more details
https://docs.microsoft.com/en-us/powershell/module/dnsserver/remove-dnsserverzone
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hi,
Assuming there is a column of names with the column header "Name" in the CSV file, you can try to run the below PowerShell script as administrator. The Remove-DnsServerResourceRecord cmdlet removes specified records from a zone. The name of the DNS zone also has to be specified.
$file = "C:\temp\records.csv"
$zone = "contoso.com"
Import-Csv -Path $file | ForEach-Object {
Remove-DnsServerResourceRecord -Name $_.name -ZoneName $zone -RRType A -Force
}
https://docs.microsoft.com/en-us/powershell/module/dnsserver/remove-dnsserverresourcerecord
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hello,
I just want to delete the domain name of the conditional forwarder in the csv file,for example:
get-dnsserverzone | where-Object{$_.zonetype -eq "Forwarder"} | remove-dnsserverzone .
How to write this script?Thank you!
I am test is ok.
$file = "C:\DNS.csv"
Import-Csv -Path $file | ForEach-Object {
Remove-DnsServerZone -Name $_.name -PassThru -Verbose -force
}
10 people are following this question.