PowerShell command to force Active Directory replication

What is the Server 2016 PowerShell command to force Active Directory replication between domain controllers so that newly created user and computer accounts will be replicated to the other domain controllers?
IT GuyNetwork EngineerAsked:
Who is Participating?
 
SquigglyMonkeyCommented:
This previous question, looks to answer yours.
Previous EE question
1
 
oBdACommented:
Basically with Sync-ADObject.
More specifically:
1. Choose a source DC on which to create the object, and use it with the -Server parameter when working with the New-AD... cmdlets.
2. Collect the other DCs.
3. Create the object (will be returned by the cmdlet),
4. Use the new object's DistinguishedName to replicate it to the other DCs.
## FQDN of the source DC; can be hardcoded, $ENV:ComputerName (if on a DC), randomly picked, or something like (Get-ADDomain).PDCEmulator
$Source = (Get-ADDomain).PDCEmulator
## Create a list with the rest of the DCs:
$Destination = Get-ADDomainController | Select-Object -ExpandProperty HostName | Where-Object {$_ -ne $Source}
## Now create the objects
ForEach (<Whatever>) {
	$NewObject = New-ADUser -Server $Source ...
	## Start replication of the new object from the source DC to the other DCs:
	$Destination | ForEach-Object {Sync-ADObject -Object $NewObject.DistinguishedName -Source $Source -Destination $_}
}

Open in new window

Or the brute force method with repadmin.exe:
## FQDN of the source DC; can be hardcoded, randomly picked, or something like (Get-ADDomain).PDCEmulator
$Source = (Get-ADDomain).PDCEmulator
## Create all the objects first:
ForEach (<Whatever>) {
	$NewObject = New-ADUser -Server $Source ...
}
## Then force an outbound replication:
repadmin.exe /syncall /Ped $Source "DC=domain,dc=com"

Open in new window

1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.