複寫 Active Directory 和拓撲管理,使用 Windows PowerShell (層級 100) 簡介Introduction to Active Directory Replication and Topology Management Using Windows PowerShell (Level 100)

適用於:Windows Server 2016、Windows Server 2012 R2、Windows Server 2012Applies To: Windows Server 2016, Windows Server 2012 R2, Windows Server 2012

Windows PowerShell 的 Active Directory 包含管理複寫、網站、網域及森林、網域控制站和磁碟分割的能力。Windows PowerShell for Active Directory includes the ability to manage replication, sites, domains and forests, domain controllers, and partitions. 使用者的先前管理工具,例如的 Active Directory 網站和服務] 嵌入式管理單元,repadmin.exe 將會注意到類似的功能現在已可使用的 Active Directory 操作 Windows PowerShell 中的。Users of prior management tools such as the Active Directory Sites and Services snap-in and repadmin.exe will notice that similar functionality is now available from within the Windows PowerShell for Active Directory context. 此外,cmdlet 的現有 Windows PowerShell 的 Active Directory cmdlet,因此建立精簡的體驗,並允許輕鬆建立自動化的指令碼針對相容。In addition, the cmdlets are compatible with the existing Windows PowerShell for Active Directory cmdlets, thus creating a streamlined experience and allowing customers to easily create automation scripts.

注意

Windows PowerShell cmdlet 拓撲複寫 Active Directory,可在下列環境中:The Windows PowerShell for Active Directory replication and topology cmdlets are available in the following environments:

  • Windows Server 2012 網域控制站Windows Server 2012 domain controller
  • Windows Server 2012 的遠端伺服器管理工具 AD DS 和 AD LDS 安裝。Windows Server 2012 with the Remote Server Administration Tools for AD DS and AD LDS installed.
  • Windows®使用遠端伺服器管理工具 AD DS 和 AD LDS 安裝 8。Windows® 8 with the Remote Server Administration Tools for AD DS and AD LDS installed.

安裝 Windows PowerShell 模組 Active DirectoryInstalling the Active Directory Module for Windows PowerShell

AD DS 伺服器角色執行 Windows Server 2012 的伺服器上安裝時,預設會安裝 Active Directory 模組適用於 Windows PowerShell。The Active Directory Module for Windows PowerShell is installed by default when the AD DS server role is installed on a server that runs Windows Server 2012 . 任何額外的步驟不會需要以外新增伺服器角色。No additional steps are required other than adding the server role. 您也可以安裝 Active Directory 模組伺服器執行,安裝遠端伺服器管理工具,Windows Server 2012 上,您可以安裝 Active Directory 模組執行來下載並安裝 Windows 8 電腦上遠端伺服器管理工具 (RSAT)You can also install the Active Directory Module on a server that runs Windows Server 2012 by installing the Remote Server Administration Tools, and you can install the Active Directory Module on a computer running Windows 8 by downloading and installing the Remote Server Administrative Tools (RSAT). 查看的指示如安裝步驟。See Instructionsfor installation steps.

適用於 Windows PowerShell Active Directory 複寫和拓撲管理 cmdlet 測試案例Scenarios for testing Windows PowerShell for Active Directory replication and topology management cmdlets

下列案例的設計系統管理員,管理新 cmdlet 熟悉:The following scenarios are designed for administrators to familiarize themselves with the new management cmdlets:

  • 取得所有網域控制站與他們對應的網站清單Get a list of all domain controllers and their corresponding sites

  • 管理複寫拓撲Manage replication topology

  • 檢視複寫狀態和資訊View replication status and information

實驗室需求Lab Requirements

  • 有兩個 Windows Server 2012 網域控制站:DC1DC2的一部分 contoso.com 網域和位於網域中的公司的網站。Two Windows Server 2012 domain controllers: DC1 and DC2 that are part of the contoso.com domain and reside in the CORPORATE site within that domain.

檢視網域控制站與他們的網站View domain controllers and their sites

在此步驟,您將會使用 Active Directory 模組適用於 Windows PowerShell 檢視現有的網域控制站及複寫拓撲的網域。In this step, you will use the Active Directory Module for Windows PowerShell to view the existing domain controllers and the replication topology for the domain.

若要完成下列程序中的步驟,您必須網域管理群組成員或有相當權限。To complete the steps in the following procedures, you must be a member of the Domain Admins group or have equivalent permissions.

若要檢視所有的 Active Directory 網站To view all Active Directory sites

  1. DC1,按一下 [ Windows PowerShell在工作列上。On DC1, click Windows PowerShell on the taskbar.

  2. 輸入下列命令:Type the following command:

    Get-ADReplicationSite -Filter *

    這會每個網站的相關詳細的資訊。This returns detailed information about each site. Filter在 Active Directory PowerShell cmdlet 使用參數限制傳回物件的清單。The Filter parameter is used throughout Active Directory PowerShell cmdlets to limit the list of objects returned. 此時,請星號()會顯示所有網站的物件。In this case, the asterisk () indicates all site objects.

    提示

    Windows PowerShell 中,您可以使用 Tab 鍵在自動完成的命令。You can use the Tab key to auto-complete commands in Windows PowerShell.

    範例:輸入Get-ADRep和多次按 tab 鍵,直到符合命令略過Get-ADReplicationSiteExample: Type Get-ADRep and press Tab multiple times to skip through the matching commands until you reach Get-ADReplicationSite. 自動完成也適用於參數名稱為FilterAuto-complete also works for parameter names such as Filter.

    要格式化的輸出Get-ADReplicationSite命令為表格和限制顯示到特定的欄位,您可以管道輸出到Format-Table命令 (或」ft」的簡短):To format the output from the Get-ADReplicationSite command as a table and limit the display to specific fields, you can pipe the output to the Format-Table command (or "ft" for short):

    Get-ADReplicationSite -Filter * | ft Name

    這會傳回的網站清單,包括名稱欄位較短的版本。This returns a shorter version of the site list, including only the Name field.

製作所有網域控制站的表格To produce a table of all domain controllers

  • 輸入下列命令,Windows PowerShell 模組 Active Directory命令提示字元中:Type the following command at the Active Directory module for Windows PowerShell prompt:

    Get-ADDomainController -Filter * | ft Hostname,Site

    此命令傳回網域控制站裝載的名稱,以及它們的網站的關聯。This command returns the domain controllers host name as well as their site associations.

管理複寫拓撲Manage replication topology

在上一個步驟中,執行命令之後,Get-ADDomainController -Filter * | ft Hostname,SiteDC2已列於公司的網站。In the previous step, after running the command, Get-ADDomainController -Filter * | ft Hostname,Site, DC2 was listed as part of the CORPORATE site. 在下列程序,您將會建立新的分支 office 網站,分支 1建立新的網站連結、設定的網站連結成本和複寫頻率,然後將DC2分支 1In the procedures below, you will create a new branch office site, BRANCH1, create a new site link, set the site link cost and replication frequency and then move DC2 to BRANCH1.

若要完成下列程序中的步驟,您必須網域管理群組成員或有相當權限。To complete the steps in the following procedures, you must be a member of the Domain Admins group or have equivalent permissions.

若要建立新的網站To create a new site

  • 輸入下列命令,Windows PowerShell 模組 Active Directory命令提示字元中:Type the following command at the Active Directory module for Windows PowerShell prompt:

    New-ADReplicationSite BRANCH1

    這個命令建立的新分支」office 網站,分支 1。This command creates the new branch office site, branch1.

  • 輸入下列命令,Windows PowerShell 模組 Active Directory命令提示字元中:Type the following command at the Active Directory module for Windows PowerShell prompt:

    New-ADReplicationSiteLink 'CORPORATE-BRANCH1' -SitesIncluded CORPORATE,BRANCH1 -OtherAttributes @{'options'=1}

    這個命令建立的網站連結分支 1並已變更通知程序。This command created the site link to BRANCH1 and turned on the change notification process.

    提示

    使用索引標籤自動完成參數名稱,例如-SitesIncluded-OtherAttributes除了手動輸入出。Use Tab to auto-complete parameter names such as -SitesIncluded and -OtherAttributes rather than typing them out manually.

  • 輸入下列命令,Windows PowerShell 模組 Active Directory命令提示字元中:Type the following command at the Active Directory module for Windows PowerShell prompt:

    Set-ADReplicationSiteLink CORPORATE-BRANCH1 -Cost 100 -ReplicationFrequencyInMinutes 15

    設定的網站連結成本為分支 1100,並將網站的頻率15 分鐘This command sets the site link cost to BRANCH1 at 100 and set the replication frequency with the site to 15 minutes.

網域控制站移動到不同的網站To move a domain controller to a different site

  • 輸入下列命令,Windows PowerShell 模組 Active Directory命令提示字元中:Type the following command at the Active Directory module for Windows PowerShell prompt:

    Get-ADDomainController DC2 | Move-ADDirectoryServer -Site BRANCH1

    這個命令移動網域控制站DC2分支 1的網站。This command moves the domain controller, DC2 to the BRANCH1 site.

驗證Verification

  • 按一下伺服器管理員,按一下 [工具,然後按一下 [ Active Directory 網站和服務,並確認動作:Click Server Manager, click Tools and then click Active Directory Sites and Services and verify the following:

    確認分支 1網站包含所有的 Windows PowerShell 命令正確的值。Verify that the BRANCH1 site contains all of the correct values from the Windows PowerShell commands.

    確認公司-分支 1會建立網站的連結,並連接分支 1公司網站。Verify the CORPORATE-BRANCH1 site link is created and connects the BRANCH1 and CORPORATE sites.

    確認DC2現在已在分支 1的網站。Verify DC2 is now in the BRANCH1 site. 或者,您可以開放Active Directory 模組適用於 Windows PowerShell,輸入下列命令,以確認DC2現在已在 [分支 1網站:Get-ADDomainController -Filter * | ft Hostname,SiteAlternatively, you can open the Active Directory Module for Windows PowerShell and type the following command to verify DC2 is now in the BRANCH1 site: Get-ADDomainController -Filter * | ft Hostname,Site.

檢視複寫狀態的資訊View replication status information

下列程序,您將會使用 Windows PowerShell 中的其中一個複寫 Active Directory 和管理 cmdlet,Get-ADReplicationUpToDatenessVectorTable DC1,若要使用的最新向量表格維護的每個網域控制站的簡單複寫報告。In the following procedures, you will use one of the Windows PowerShell for Active Directory replication and management cmdlets, Get-ADReplicationUpToDatenessVectorTable DC1, to produce a simple replication report using the up-to-dateness vector table maintained by each domain controller. 森林中的每個網域控制站從看到最高原始寫入 USN 保留的最新向量本表。This up-to-dateness vector table keeps track of the highest originating write USN seen from each domain controller in the forest.

若要完成下列程序中的步驟,您必須網域管理群組成員或有相當權限。To complete the steps in the following procedures, you must be a member of the Domain Admins group or have equivalent permissions.

若要檢視最新的單一網域控制站向量表格To view the up-to-dateness vector table for a single domain controller

  1. 輸入下列命令,Windows PowerShell 模組 Active Directory命令提示字元中:Type the following command at the Active Directory module for Windows PowerShell prompt:

    Get-ADReplicationUpToDatenessVectorTable DC1

    這會顯示一份最高的 Usn 所見DC1針對每個森林中的網域控制站。This shows a list of the highest USNs seen by DC1 for every domain controller in the forest. 伺服器值指伺服器維護表格,這種情形下DC1The Server value refers to the server maintaining the table, in this case DC1. 合作夥伴所進行的變更︰ 複寫合作夥伴(直接或間接)是指值。The Partner value refers to the replication partner (direct or indirect) on which changes were made. UsnFilter 價值,是最高 USN 所見DC1的合作夥伴。The UsnFilter value is the highest USN seen by DC1 from Partner. 森林中新增了新的網域控制站,如果這不會出現在DC1直到的表格DC1收到來自新的網域的變更。If a new domain controller is added to the forest, it will not appear in DC1's table until DC1 receives a change that originated from the new domain.

若要檢視所有網域控制站的最新向量表格網域中To view the up-to-dateness vector table for all domain controllers in a domain

  1. 在 Active Directory 模組的 Windows PowerShell 命令提示字元中輸入下列命令:Type the following command at the Active Directory module for Windows PowerShell prompt:

    Get-ADReplicationUpToDatenessVectorTable * | sort Partner,Server | ft Partner,Server,UsnFilter

    這個命令取代DC1*,因此收集的所有網域控制站的最新向量表格資料。This command replaces DC1 with *, thus collecting the up-to-dateness vector table data from all domain controllers. 資料會依合作夥伴伺服器,然後在表格中顯示。The data is sorted by Partner and Server and then displayed in a table.

    排序可讓您輕鬆地比較最後 USN 的每個網域控制站看見的特定的複寫合作夥伴。The sorting allows you to easily compare the last USN seen by each domain controller for a given replication partner. 這是快速查看該複寫在您的環境。This is a quick way to check that replication is occurring across your environment. 如果複寫正確運作,回報特定的複寫合作夥伴 UsnFilter 值應相似所有網域控制站。If replication is working correctly, the UsnFilter values reported for a given replication partner should be fairly similar across all domain controllers.

也了See Also

進階複寫 Active Directory 和拓撲管理,使用 Windows PowerShell 與 #40;層級 200 和 #41;Advanced Active Directory Replication and Topology Management Using Windows PowerShell (Level 200)