question

uranus12 avatar image
0 Votes"
uranus12 asked IanXue-MSFT answered

How to delete the dns forwarder in the specified csv 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?

windows-server-2019
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered IanXue-MSFT edited

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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

uranus12 avatar image
0 Votes"
uranus12 answered

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!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

uranus12 avatar image
0 Votes"
uranus12 answered

I am test is ok.
$file = "C:\DNS.csv"
Import-Csv -Path $file | ForEach-Object {
Remove-DnsServerZone -Name $_.name -PassThru -Verbose -force
}

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.