All scripts
Azure AI 258
Get-AzureDnsZoneReport
Exports every record set from every Azure DNS zone in the subscription to CSV, giving you an offline reference of the tenant's actual DNS configuration.
Get-AzureDnsZoneReport.ps1
<#
.SYNOPSIS
Exports all DNS record sets from every Azure DNS zone.
.DESCRIPTION
Walks every DNS zone in the subscription and exports its record sets
to a single CSV, giving you an offline, reviewable reference of the
tenant's actual DNS configuration instead of relying on memory or
outdated documentation.
.PARAMETER ExportPath
Path to write the CSV to. Defaults to the current directory.
.EXAMPLE
.\Get-AzureDnsZoneReport.ps1
.NOTES
Requires the Az.Dns module and an active Connect-AzAccount session.
.AUTHOR
Shehryar Hassan
#>
param(
[string]$ExportPath = (Get-Location).Path
)
$zones = Get-AzDnsZone
$report = foreach ($zone in $zones) {
$recordSets = Get-AzDnsRecordSet -ZoneName $zone.Name -ResourceGroupName $zone.ResourceGroupName
foreach ($record in $recordSets) {
[pscustomobject]@{
Zone = $zone.Name
RecordName = $record.Name
Type = $record.RecordType
TTL = $record.Ttl
}
}
}
$file = Join-Path $ExportPath "dns-zone-export_$(Get-Date -Format yyyyMMdd_HHmmss).csv"
$report | Export-Csv -Path $file -NoTypeInformation
Write-Host "Exported $($report.Count) record(s) across $($zones.Count) zone(s) to $file" -ForegroundColor Cyan
Read it before you run it, and test in a safe tenant first.