Search
Windows Server

Windows Server 2012 : Administering Active Directory using Windows PowerShell (part 3) - Performing an advanced Active Directory administration task

Published 2 min read By Programming4us Editorial Team

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:

  1. Create a new site named Branch-Office-One for the Bellevue location.

  2. Create a new site link named Hub-to-Branch-Office-One to enable replication to occur between the two sites.

  3. 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:

  1. List all the sites that currently exist in the domain:

    PS C:\> Get-ADReplicationSite -Filter * | ft Name

    Name
    ----
    Default-First-Site-Name
  2. 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
  3. Create a new site named Branch-Office-One:

    PS C:\> New-ADReplicationSite Branch-Office-One
  4. Verify the creation of the new site:

    PS C:\> Get-ADReplicationSite -Filter * | ft Name

    Name
    ----
    Default-First-Site-Name
    Branch-Office-One
  5. 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}
  6. Specify the cost and replication frequency for the new site link:

    PS C:\>Set-ADReplicationSiteLink Hub-to-Branch-Office-One `
    -Cost 100 -ReplicationFrequencyInMinutes 15
  7. 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}
  8. 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
  9. 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.)

This MMC console confirms what the Windows PowerShell cmdlets accomplished.

Figure 5-16. This MMC console confirms what the Windows PowerShell cmdlets accomplished.