When the first domain controller is introduced into the infrastructure, the system creates its first site as Default-First-Site-Name. This can be changed based on the requirements. We can review the existing sites configuration using the following PowerShell cmdlet:
Get-ADReplicationSite -Filter *
It will list down the sites information for the AD infrastructure.
In our example, it only has the default Active Directory site. As the first step, I need to change it to a meaningful name, so we can assign objects and configurations accordingly. In order to do that, we can use the Rename-ADObject cmdlet:
Rename-ADObject -Identity "CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=rebeladmin,DC=com" -NewName "LondonSite"
The preceding command will rename the Default-First-Site-Name site to LondonSite. In the existing site, we can change the values using the Set-ADReplicationSite cmdlet:
Get-ADReplicationSite -Identity LondonSite | Set-ADReplicationSite -Description "UK AD Site"
The preceding command changed the site description to UK AD Site.
We can create a new AD site using the New-ADReplicationSite cmdlet. The full description of the command can be viewed using Get-Command New-ADReplicationSite -Syntax:
New-ADReplicationSite -Name "CanadaSite" -Description "Canada AD Site"
The preceding command will create a new AD site called CanadaSite:
Once sites are created, we need to move the domain controllers to the relevant site. By default, all the domain controllers are placed under the default site, Default-First-Site-Name.
In the following command, I am listing down all the domain controllers in the Active Directory infrastructure with filtered data to show the Name,ComputerObjectDN,Site attributes values:
Get-ADDomainController -Filter * | select Name,ComputerObjectDN,Site | fl
Now, we have the list of domain controllers, and as the next step, we can move the domain controller to the relevant site:
Move-ADDirectoryServer -Identity "REBEL-SDC-02" -Site "CanadaSite"
The preceding command will move the REBEL-SDC-02 domain controller to CanadaSite.