Public/Export-DNSServerIPConfig.ps1
Function Export-DNSServerIPConfig { param( [Parameter(Mandatory)]$DomainList ) # Get the DNS configuration of each child DC $DNSReport = @() ForEach ($Domain in $DomainList) { # Get a list of DCs without using AD Web Service $DCs = netdom query /domain:$Domain dc | Where-Object { $_ -notlike "*accounts*" -and $_ -notlike "*completed*" -and $_ } ForEach ($dc in $DCs) { # Forwarders $dnsFwd = Get-WMIObject -ComputerName $("$dc.$Domain") ` -Namespace root\MicrosoftDNS -Class MicrosoftDNS_Server ` -ErrorAction SilentlyContinue # Primary/Secondary (Self/Partner) # http://msdn.microsoft.com/en-us/library/windows/desktop/aa393295(v=vs.85).aspx $nic = Get-WMIObject -ComputerName $("$dc.$Domain") -Query ` "Select * From Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE" ` -ErrorAction SilentlyContinue $DNSReport += 1 | Select-Object ` @{name = "DC"; expression = { $dc } }, ` @{name = "Domain"; expression = { $Domain } }, ` @{name = "DNSHostName"; expression = { $nic.DNSHostName } }, ` @{name = "IPAddress"; expression = { $nic.IPAddress } }, ` @{name = "DNSServerAddresses"; expression = { $dnsFwd.ServerAddresses } }, ` @{name = "DNSServerSearchOrder"; expression = { $nic.DNSServerSearchOrder } }, ` @{name = "Forwarders"; expression = { $dnsFwd.Forwarders } }, ` @{name = "BootMethod"; expression = { $dnsFwd.BootMethod } }, ` @{name = "ScavengingInterval"; expression = { $dnsFwd.ScavengingInterval } } } # End ForEach } $DNSReport | Format-Table -AutoSize -Wrap $DNSReport | Export-Csv ".\Report_DomainControllerDNSConfig_$(Get-Date -UFormat %Y%m%d%H%M%S).csv" -NoTypeInformation } |