from a txt file with the hostname names I would like to delete all type a records in DNS
get-content -path c:\temp\ListHost.txt
from a txt file with the hostname names I would like to delete all type a records in DNS
get-content -path c:\temp\ListHost.txt
What about the associated PTR records (assuming you have a reverse lookup zone for the IP addresses)?
Are there any CNAME records (or any other record types) that are refer to the A record(s)?
The same records are in the reverse zone and I want to delete them
Hi @joaomanoelc ,
please try this (the -force needs to be inside the {}):
Get-Content -path c:\temp\ListHost.txt | ForEach {Remove-DnsServerResourceRecord -ZoneName "contoso.com" -RRType "A" -Name "$" -Force}
To remove the PTR record the -RRType needs to be Ptr.
Maybe this helps:
https://rcmtech.wordpress.com/2014/02/26/get-and-delete-dns-a-and-ptr-records-via-powershell/
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten
Andreas, thank you very much the command was successfully executed.
I will need to delete the PTR records I will analyze the link you provided here and if I can't I will record another question.
I will mark as an answer
Hi @joaomanoelc ,
maybe this helps to get started (not tested by myself!):
Get-Content -path c:\temp\ListHost.txt | ForEach {Remove-DnsServerResourceRecord -ZoneName "contoso.com" -RRType "A" -Name "$_"}
You have to modify the ZoneName for you needs.
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten
your command works for remove and list, but by putting -Confirm:$false or -force the powershell informs you that the parameter is not supported.
I have a list of 100 records that I need to delete and it would be nice not to have to confirm the deletion of each record.
Get-Content -path c:\temp\ListHost.txt | ForEach {Remove-DnsServerResourceRecord -ZoneName "contoso.com" -RRType "A" -Name "$"} -force
Get-Content -path c:\temp\ListHost.txt | ForEach {Remove-DnsServerResourceRecord -ZoneName "contoso.com" -RRType "A" -Name "$"} -Confirm:$false
11 people are following this question.