Skip to content

Instantly share code, notes, and snippets.

@jangins101
Created May 25, 2016 14:54
Show Gist options
  • Save jangins101/61001526ee976d22f90ab45d0f226925 to your computer and use it in GitHub Desktop.
Save jangins101/61001526ee976d22f90ab45d0f226925 to your computer and use it in GitHub Desktop.
Grab all the dns zones and their corresponding records and group it by zone name
$computer = $env:USERDNSDOMAIN;
# Get all the zones
$zones = @(Get-DnsServerZone -ComputerName $computer);
# Get records from each zone
$results = @{};
ForEach ($zone in $zones) {
Write-Host "$($zone.ZoneName)" -ForegroundColor Yellow -NoNewline;
$zoneRecords = @($zone | Get-DnsServerResourceRecord -ComputerName $computer);
Write-Host " - $($zoneRecords.Count) records" -ForegroundColor Green;
$results.Add($zone.ZoneName, $zoneRecords);
}
$results;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment