guyrleech

Get All DNS Records for All Zones

May 27th, 2022 (edited)
197
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## Get all DNS records for all DNS zones
  2. Import-Module -Name DnsServer
  3. [string]$dnsserver = "yourdnsserver"
  4. ## Pipe this through Out-GridView or ExportCSV -NoTypeInformation
  5. Get-DnsServerZone -ComputerName $dnsserver | ForEach-Object { $zone = $_ ; Get-DnsServerResourceRecord -ComputerName $dnsserver -ZoneName $zone.zoneName | Select -ExcludeProperty Cim* -Property @{n="ZoneName";e={$zone.zonename}},@{n='IPv4Address';e={$_.RecordData.IPv4Address}},* }
  6.  
RAW Paste Data Copied