Public/Export-DNSServerZoneInfo.ps1
Function Export-DNSServerZoneInfo { param( [Parameter(Mandatory)]$DomainList ) # This report assumes that all DCs are running DNS. $Report = @() ForEach ($Domain in $DomainList) { # Get a list of DCs without using AD Web Service # You may see RiverBed devices returned in this list. $DCs = netdom query /domain:$Domain dc | Where-Object { $_ -notlike "*accounts*" -and $_ -notlike "*completed*" -and $_ } ForEach ($dc in $DCs) { $DCZones = $null Try { $DCZones = Get-DnsServerZone -ComputerName $("$dc.$Domain") | Select-Object @{Name = "Domain"; Expression = { $Domain } }, @{Name = "Server"; Expression = { $("$dc.$Domain") } }, ZoneName, ZoneType, DynamicUpdate, IsAutoCreated, IsDsIntegrated, IsReverseLookupZone, ReplicationScope, DirectoryPartitionName, MasterServers, NotifyServers, SecondaryServers ForEach ($Zone in $DCZones) { If ($Zone.ZoneType -eq 'Primary') { $ZoneAging = Get-DnsServerZoneAging -ComputerName $("$dc.$Domain") -ZoneName $Zone.ZoneName | Select-Object ZoneName, AgingEnabled, NoRefreshInterval, RefreshInterval, ScavengeServers Add-Member -InputObject $Zone -MemberType NoteProperty -Name AgingEnabled -Value $ZoneAging.AgingEnabled Add-Member -InputObject $Zone -MemberType NoteProperty -Name NoRefreshInterval -Value $ZoneAging.NoRefreshInterval Add-Member -InputObject $Zone -MemberType NoteProperty -Name RefreshInterval -Value $ZoneAging.RefreshInterval Add-Member -InputObject $Zone -MemberType NoteProperty -Name ScavengeServers -Value $ZoneAging.ScavengeServers } Else { Add-Member -InputObject $Zone -MemberType NoteProperty -Name AgingEnabled -Value $null Add-Member -InputObject $Zone -MemberType NoteProperty -Name NoRefreshInterval -Value $null Add-Member -InputObject $Zone -MemberType NoteProperty -Name RefreshInterval -Value $null Add-Member -InputObject $Zone -MemberType NoteProperty -Name ScavengeServers -Value $null } } $Report += $DCZones } Catch { Write-Warning "Error connecting to $dc.$Domain." } } # End ForEach } $Report | Export-Csv -Path ".\Report_DNSZones_$(Get-Date -UFormat %Y%m%d%H%M%S).csv" -NoTypeInformation -Force -Confirm:$false } |