我正在尝试在从 .txt 文件加载的现有站点中创建子网。我的代码如下所示:
<#Add subnets to matching sites#>
$i=0
foreach($_ in $subnetList){
$currentSites = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites
if($currentSites.Subnets -match $_){
continue
}else{
New-ADReplicationSubnet -Name $_ -Site $siteList[$i]
$i++
}
}
$subnetList
和有以下$siteList
内容:
$subnetList =
10.0.0.0/21
10.0.5.0/21
10.0.9.0/24
10.0.11.0/24
10.0.14.0/24
10.0.19.0/24
<#SITENAME1 has 2 occurences.#>
$siteList =
SITENAME1
SITENAME1
SITENAME2
SITENAME3
SITENAME4
SITENAME5
我遇到的问题是,当 SITENAME1 添加了第一个子网时,它在第二次尝试时返回错误:
New-ADReplicationSubnet : An attempt was made to add an object to the directory
with a name that is already in use
有什么方法可以向该站点添加额外的子网吗?Technet 谈到了这种-Instance
开关。恐怕我不确定如何实施。