SID-500

Home » PowerShell » Active Directory: Force replication of all Domain Controllers on all Sites at once

Active Directory: Force replication of all Domain Controllers on all Sites at once

Active Directory Domain Services uses pull replication to replicate Active Directory Partitions. This means that the Domain Controller on which replication is started receives the data from the source Domain Controller. It’s like a one way ticket.

If you want to replicate all Domain Controllers, then you have to start replication on each of them separately. This may take a while. To save time, I am going to show you a PowerShell One-Liner to force replication on all Domain Controllers of all Active Directory Sites. Let’s take a look at this One-Liner now.

Force Replication of all Domain Controllers on all Sites

Suppose, you have one Domain with multiple sites. (One Forest and one Forest Root Domain).

Log on to one of your Domain Controllers. Start Windows PowerShell with administrative privileges. The domain name and the domain partition doesn’t need to be specified. It will be filled automatically by Get-ADDomain. 😉

(Get-ADDomainController -Filter *).Name  | Foreach-Object {repadmin /syncall $_ (Get-ADDomain).DistinguishedName /e /A | Out-Null}; Start-Sleep 10; Get-ADReplicationPartnerMetadata -Target "$env:userdnsdomain" -Scope Domain | Select-Object Server, LastReplicationSuccess

Unbenannt.PNG

Once completed, you get a nice overview with the computer names of the Domain Controllers and the time of the Last Replication Success.

Unbenannt.PNG

That’s it.

Have fun replicating your DC’s! More about repadmin here:

https://technet.microsoft.com/en-us/library/cc835086(v=ws.11).aspx

See also

PowerShell: Adding Active Directory Users from Text Files (Bulk)

Windows Server 2016: Configuring Time based Group Membership with PowerShell

PowerShell: Changing Active Directory user logon names (Bulk)


4 Comments

  1. Tobi says:

    Would be very helpful if you could explain what these powershell-snippets actually do. Such one-liners are often a little hard to read.

    Like

    • pewa2303 says:

      You only have to pay attention to the first two lines. Get-ADDomainController receives the Names of all DCs. This names are then piped to Foreach-Object that runs repadmin on all of them with no ouput (Out-Null). Then the script goes to sleep for 10 seconds. Afterwards ReplicationData from all DCs are retreived to view the replication status.

      For some it’s hard to read for others not. I love it.
      But yes, in complex scripts it’s more useful to use the common script struture.

      Like

    • pewa2303 says:

      The purpose of Start-Sleep is to wait a few seconds. You can skip that. It’s just to make sure that Get-ADReplicationMetaData gets the recent results.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

GET-AUTHOR

My name is Patrick Grünauer. Microsoft MVP. I am from Austria. On sid-500 I write about Windows, Cisco and IT-Security in English and German. Have fun while reading!

Categories

Patrick Gruenauer
Follow SID-500 on WordPress.com