Windows Server 2012 : Administering Active Directory using Windows PowerShell (part 3) - Performing an advanced Active Directory administration task
Performing an advanced Active Directory administration task
I’ll conclude this lesson with an example of how to perform an advanced Active Directory administration task using Windows PowerShell. Here is the scenario:
Contoso Ltd. is in the process of rolling out its Active Directory environment at its headquarters in Seattle. So far, two domain controllers have been deployed at this location. A new branch office is going to be set up in Bellevue, and the Contoso administrator has decided to move one of the existing domain controllers to this new location.
Here are the steps that the administrator will perform:
-
Create a new site named Branch-Office-One for the Bellevue location.
-
Create a new site link named Hub-to-Branch-Office-One to enable replication to occur between the two sites.
-
Move one of the two domain controllers from Default-First-Site-Name to Branch-Office-One.
This is how it might be done using Windows PowerShell:
-
List all the sites that currently exist in the domain:
PS C:\> Get-ADReplicationSite -Filter * | ft Name
Name
----
Default-First-Site-Name -
List all the domain controllers in the domain:
PS C:\> Get-ADDomainController -Filter * | ft Hostname
Hostname
--------
SEA-SRV-1.corp.contoso.com
SEA-SRV-5.corp.contoso.com -
Create a new site named Branch-Office-One:
PS C:\> New-ADReplicationSite Branch-Office-One
-
Verify the creation of the new site:
PS C:\> Get-ADReplicationSite -Filter * | ft Name
Name
----
Default-First-Site-Name
Branch-Office-One -
Create a new site link between the two sites, and enable the change-notification process for replication:
PS C:\> New-ADReplicationSiteLink 'Hub-to-Branch-Office-One' `
-SitesIncluded Default-First-Site-Name,Branch-Office-One `
-OtherAttributes @{'options'=1} -
Specify the cost and replication frequency for the new site link:
PS C:\>Set-ADReplicationSiteLink Hub-to-Branch-Office-One `
-Cost 100 -ReplicationFrequencyInMinutes 15 -
Verify the results by viewing the properties of the new site link:
PS C:\>Get-ADReplicationSiteLink -Filter {Name -eq "Hub-to-Branch-Office-One"}
Cost : 100
DistinguishedName : CN=Hub-to-Branch-Office-One,CN=IP,CN=Inter-Site
Transports,CN=Sites,CN=Configuration,
DC=corp,DC=contoso,DC=com
Name : Hub-to-Branch-Office-One
ObjectClass : siteLink
ObjectGUID : f9df8b3c-f8bc-4ca9-b082-09655e14c80b
ReplicationFrequencyInMinutes : 15
SitesIncluded : {CN=Branch-Office-One,CN=Sites,CN=Configuration,
DC=corp,DC=contoso,DC=com,CN=Default-First-
Site-Name,CN=Sites,CN=Configuration,DC=corp,
DC=contoso,DC=com} -
Move domain controller SEA-SRV-5 from the hub site to the branch office site:
PS C:\> Get-ADDomainController SEA-SRV-5.corp.contoso.com | `
Move-ADDirectoryServer -Site Branch-Office-One -
Verify that the domain controller has been moved to the branch office site:
PS C:\> Get-ADDomainController -Filter * | ft Hostname,Site
Hostname Site
-------- ----
SEA-SRV-1.corp.contoso.com Default-First-Site-Name
SEA-SRV-5.corp.contoso.com Branch-Office-One
Finally, opening the Active Directory Sites And Services MMC console shows the expected configuration of sites, site links, and domain controllers. (See Figure 2.)
Figure 5-16. This MMC console confirms what the Windows PowerShell cmdlets accomplished.