Get DNS forwarder from forest

#Domain names in forest

$ForestInfo = Get-ADForest
$Domains =$forestInfo.domains
$FileName = “DNSForwarder”+”$(get-date -Format MM-dd-yyyy)”+”.csv”
$FilePath = “c:\temp”
foreach($domain in $domains){
Write-Output “Working on $domain”
get-dnsserverforwarder -computer $domain| select IPAddress, @{l=”Domain”;e={$domain}}| Export-Csv -NoTypeInformation $FilePath\$FileName -append
}

Leave a Reply

Your email address will not be published. Required fields are marked *