Removing a set of DNS records over multiple Microsoft domains can be a bit of a hassle sometimes. With PowerShell it’s rather easy by using the Get-DnsServerResourceRecord. Here is a small example of how to use this cmdlet.
$dnsRecord = "*test*" $parameters = @{ ZoneName = $env:userdnsdomain ComputerName = $env:userdnsdomain } $records = Get-DnsServerResourceRecord @parameters | Where-Object {$_.HostName -like $dnsRecord -or $_.RecordData -like $dnsRecord} $records $records | Remove-DnsServerResourceRecord @parameters
First we retrieve all DNS records in our current domain that have test
in the name.
Then we display it and the last step is the removal. Without the `-confirm:$false` switch the Remove-DnsServerResourceRecord cmdlet will ask for confirmation before removing the DNS record.