Force replication to all Domain Controllers

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!

About the author