Untitled
unknown
plain_text
2 years ago
883 B
7
Indexable
Import-Module DnsServer
# Get all DNS zones
$zones = Get-DnsServerZone
# Create an empty array to store all records
$allRecords = @()
# Iterate over each zone
foreach ($zone in $zones) {
# Get all A records for the current zone
$records = Get-DnsServerResourceRecord -ZoneName $zone.ZoneName -RRType A
# Iterate over each A record
foreach ($record in $records) {
# Get the IP address associated with the A record
$ipAddress = $record.RecordData.IPv4Address.IPAddressToString
# Add record and IP address to the array
$allRecords += [PSCustomObject]@{
"ZoneName" = $zone.ZoneName
"RecordType" = $record.RecordType
"HostName" = $record.HostName
"IPAddress" = $ipAddress
}
}
}
# Export all records to CSV
$allRecords | Export-Csv -Path "dns_records.csv" -NoTypeInformation
Editor is loading...
Leave a Comment