#备份操作
#创建备份目录
md d:\dns
#筛选需要备份的条件转发,并导出
Get-DnsServerZone|?{$_.ZoneType -like "Forwarder"}|?{$_.ZoneName -like "*corp.com"}|Select-Object ZoneName,@{Name = 'MasterServers';Expression = {$_.MasterServers -join ","}},UseRecursion,ForwarderTimeout|Export-Csv -Path D:\dns\Forwarder.csv -NoTypeInformation -Encoding UTF8
#删除操作
Get-DnsServerZone|?{$_.ZoneType -like "Forwarder"}|?{$_.ZoneName -like "*corp.com"}|Remove-DnsServerZone -Force
#恢复操作
#导入备份的内容
$dns=Import-Csv D:\dns\Forwarder.csv -Encoding Default
#循环添加条件转发器(-UseRecursion 是开启递归查询)
foreach($info in $dns){
Add-DnsServerConditionalForwarderZone -Name $info.ZoneName -MasterServers $($info.MasterServers.Split(",").foreach{[System.Net.IPAddress]$_}) -ForwarderTimeout $info.ForwarderTimeout -UseRecursion
}
标签:info,ServerDNS,浅谈,Windows,_.,Forwarder,dns,MasterServers,like
From: https://blog.51cto.com/u_13504775/6169510