Public/Remove-DNSZoneReverse.ps1
Function Remove-DNSZoneReverse { param( [Parameter(Mandatory)][string]$ComputerName ) # Get all of the reverse zones except the top-level consolidated zones $Zones = Get-DnsServerZone -ComputerName $ComputerName | Where-Object { $_.ZoneType -eq 'Primary' -and $_.IsAutoCreated -eq $false -and $_.IsReverseLookupZone -eq $true } | Select-Object -ExpandProperty ZoneName | Select-Object @{name = 'SrcZone'; expression = { $_ } }, @{name = 'DestZone'; expression = { $_.Split('.')[-3..-1] -Join '.' } } | Sort-Object DestZone, SrcZone | Where-Object { $_.srcZone.Split('.').Count -gt 3 } ForEach ($Zone in $Zones) { "`n$($Zone.SrcZone)" Remove-DnsServerZone -Name $Zone.SrcZone -ComputerName $ComputerName -Confirm:$true } } |