Share via


Conditional Forwarders - Report and IP Change

Get the IPs

$DNSServers = cat C:\scripts\DCs.txt
$ErrorActionPreference = "Stop"
foreach ($DNSServer in $DNSServers)
{
Try{
[PSCustomObject]@{
#Get-DnsServerZone -ComputerName $DNSServer -Name test.com,test.net | Select-Object Masterservers,Zonename
DNSServer = $DNSServer
Zone_Name = Get-DnsServerZone -ComputerName $DNSServer -Name test.com | Select-Object -ExpandProperty Zonename
Master_Servers = Get-DnsServerZone -ComputerName $DNSServer -Name test.com | Select-Object -ExpandProperty Masterservers
}
 }
catch
{
Write-Host "That Conditional forwarder is not availablle in $DNSServer" -ForegroundColor White -BackgroundColor Red
 
}
 }

Modify the IPs

 <#CSV Format
server,zone,ip
ANA-DC01.Contoso.com,test.com,"99.99.99.10,99.99.99.98"
ANA-DC03.Contoso.com,test.com,"89.89.89.56,99.99.99.13"
#>
 
$Servers = Import-csv C:\Scripts\servers.csv
foreach ($server in $Servers) 
 { 
 Set-DnsServerConditionalForwarderZone -ComputerName $Server.server -Name $Server.zone -MasterServers ($server.ip -split ",") -Verbose
 }