Force replication to all Domain Controllers

2017-12-07T10:51:33+00:00 November 17th, 2014|Azure, Cloud|

My colleague and I were chatting today and noted that there’s no command to replicate changes to all domain controllers at once, you have to go to each server and force a replicate. So here’s a nifty PowerShell script to grab all the domain controllers and run a replicate sync all command for each one – so a replicate all!

Import-Module ActiveDirectory

$DCs = (Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ } | select HostName

foreach ($DC in $DCs)
    {
        repadmin /syncall $DC.HostName
    }

Hope it helps!