Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Force Domain Controller Replication

0.00/5 (No votes)
29 Sep 2003 1  
Force Replication in a Windows AD enterprise network.

Introduction

One of the problems in a W2000 Enterprise environment is that replication of Active Directory information can take a while (according to the site information). This is specially a problem during unattended installs. The problem is that this is not really easily available in W2000. Many administrators miss this functionality when migrating from NT4 to 2000. There is a tool in W2000 which allows to replicate one domain controller with another one, but using this with many ADs is not very handy. You would have to maintain a batch file with a line per DC. The tool to replicate DC information is repadmin.

Solution

To solve this problem I made this simple VB Script. It simply reads all the DCs from AD using LDAP and fires the replication tools in separate command boxes, this makes it also multi-treaded ;-)

Copy the following text in a VBS file and alter the following things:

  • MyMainDC -> Main Domain Controller Name
  • mydomain.com -> Your domain
  • dc=mydomain,dc=com -> Your domain

The MyMainDC is to avoid the Main Domain Controller to synchronize with itself.

Run this script file any time you want to replicate the whole domain.

For me, this was enough to overcome my problems. Another option would be to take the site information in consideration. Because this is not done here, it could be that you have to run this script twice. Maybe I will change that one day.

'***********************************************

'

' Replicate.vbs

' (c) 2003, Computech, Author: Peter Verijke

'

'***********************************************

Option Explicit

Dim objDSE, strDN, objContainer, objChild, sCommand, WshShell

Set objDSE = GetObject("LDAP://rootDSE")
strDN = "OU=Domain Controllers," & objDSE.Get("defaultNamingContext")

Set objContainer = GetObject("LDAP://" & strDN)

sCommand = "%COMSPEC% /C " 
Set WshShell = WScript.CreateObject("WScript.Shell")

objContainer.Filter = Array("Computer")
For Each objChild In objContainer
    if Ucase(mid(objChild.Name,4)) <> "MyMainDC" then
        WshShell.Run(sCommand & "if exist \\" & _ 
           mid(objChild.Name,4) & "\Sysvol repadmin /syncall " _ 
           & mid(objChild.Name,4) & _ 
           ".mydomain.com dc=mydomain,dc=com /force")
    end if
Next

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here