Sites and subnets play a critical role in controlling authentication traffic and replication traffic in the Active Directory environment. In the same way we managed several logical components of Active Directory, these physical components also can be managed. However, there are no cmdlets available directly in Active Directory module to create and modify sites and subnets such as New-ADSite
, Set-ADSite
, and so on. We need to write a piece of code to query these objects using the Get-ADObject
cmdlet and modify using the Set-ADObject
cmdlet.
Sites and subnets are part of Configuration Naming Context (CNC) in Active Directory. By default, the Active Directory cmdlets query the domain naming context where the data of users, computers, groups, and OUs is stored. So, we need to tell the cmdlets to look at CNC to query sites and subnets.
First, we need to get the DN of the CNC partition, so that we can make use of it further in our code, as follows...