自动创建DNS辅助区域

 

#启用区域传送
Set-DnsServerPrimaryZone -Name "test19.com" -SecureSecondaries "TransferAnyServer"

#在其他加了域的DNS服务器上自动创建辅助区域,从启用了“允许区域复制”的DNS服务器进行复制
$dns_master_servername = "ad.test19.com"
$dns_master_serverip= "10.10.20.14"
$dnszones = Get-DnsServerZone -ComputerName $dns_master_servername  |where {("Primary" -eq $_.ZoneType) -and ($_.SecureSecondaries -eq "TransferAnyServer")} 

$dns_master_serverip = "10.10.20.14"
foreach ($dnszone in $dnszones)
{
 try {
    Get-DnsServerZone $dnszone.ZoneName  -ErrorAction stop |Out-Null
    }
catch {
    $zonefile = $dnszone.ZoneName + ".dns"
    Add-DnsServerSecondaryZone -Name $dnszone.ZoneName -ZoneFile $zonefile -MasterServers $dns_master_serverip
    }
}

 

posted on 2024-02-06 11:08  momingliu11  阅读(21)  评论(0编辑  收藏  举报