Your infrastructure may have multiple locations and, depending on those locations, many network subnets. In some cases, you may choose to use multiple network subnets to separate services even within a single data centre.
If you are using Active Directory as the directory service in your infrastructure, you need to add these subnets to ‘Sites’ under "Active Directory Sites and Services"
and ‘Subnets’ under that.
You can add subnets most simply with a few right clicks on the "Active Directory Sites and Services"
console. This is usually the method that everyone uses.
This process also has an equivalent in the PowerShell world. Although it is generally not preferred by those who do not like to work with scripts, there is no better method than this when you want to do batch processing.
If you have hundreds of subnets that you need to define, you can do it in seconds with the following script.
# CSVPath
$csvFilePath = "C:\Subnet.csv"
# CSVRead
$subnets = Import-Csv -Path $csvFilePath
#Created
foreach ($subnet in $subnets) {
$name = $subnet.Name
$site = $subnet.Site
$description = $subnet.Description
try
{New-ADReplicationSubnet -Name $name -Site $site -Description $description
Write-Host "Subnet $name added."
}catch{
Write-Host "Subnet $name failed: $_"
}
}
For mote detailed information ;
Have a nice day!