Friday, April 27, 2012

Enabling Strict Replication Via ADSI so you don't ever forget

Powershell Baby!

# Get the distinguished name of the Active Directory domain
$DomainDn = ([adsi]"").distinguishedName

# Build distinguished name path of the Operations container
$OperationsPath = "CN=Operations,CN=ForestUpdates,CN=Configuration," + $DomainDn

# Retrieve a reference to the Operations container using the path we just built
$OperationsContainer = [adsi]"LDAP://$OperationsPath"

# Create a new object inside the Operations container using the GUID, of type "container"
$StrictReplicationContainer = $OperationsContainer.Create("Container", "CN=94fdebc6-8eeb-4640-80de-ec52b9ca17fa")

# Commit the new object to the Active Directory database
$StrictReplicationContainer.SetInfo()