Solved

Force replication with a script or cammand

Posted on 2004-09-01
21
5,115 Views
Last Modified: 2008-01-09
I have 04 DC's , and I want to run a script or a a command from my desktop so that  whenever I make change in any DC it forces replication to all other domain controllers.
I know that you can do that manually in Active directory site and services.but I want something automatically.
thanks

0
Comment
Question by:Chuckbuchan
  • 12
  • 4
  • 3
  • +1
21 Comments
 
LVL 15

Expert Comment

by:scampgb
ID: 11958269
Hi Chuckbuchan,

An interesting question :-)

I've found a couple of web pages that relate to this, but they both boil down to "repadmin /syncall"

MS Article on how to do it: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnw2kmag01/html/ForcingADReplication.asp
Doing it with VB script: http://www.codeproject.com/w2k/Force_DC_Replication.asp

More info about repadmin at : http://www.microsoft.com/resources/documentation/WindowsServ/2003/all/techref/en-us/Default.asp?url=/Resources/Documentation/windowsserv/2003/all/techref/en-us/repadmin.asp

I hope that this helps.

0
 
LVL 6

Expert Comment

by:JRaster
ID: 11958625
Hmm..four DC (windows 2003) all update automaticly by default.  Is there something you are doing or that I am doing that is differant?
0
 
LVL 4

Expert Comment

by:HackLife
ID: 11960336
from: http://www.codeproject.com/w2k/Force_DC_Replication.asp

'***********************************************
'
' 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
0
 
LVL 4

Expert Comment

by:HackLife
ID: 11960343
"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" (http://www.codeproject.com/w2k/Force_DC_Replication.asp)
0
 
LVL 4

Expert Comment

by:HackLife
ID: 11960357
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.
0
 
LVL 15

Expert Comment

by:scampgb
ID: 11961202
Hi HackLife - I think all of that code was from the link I posted?
0
 
LVL 4

Expert Comment

by:HackLife
ID: 11961238
I didn't realize it was until I read your post. My apologies.
0
 

Author Comment

by:Chuckbuchan
ID: 11963427
To Hacklife : The Script didn't work as it supposed to.
I changed an attribute of a user in one DC I run your script then went to outlook ----> address book and the new attribute information wasn't replicated. exchange server is in a different DC than the one I changed in the attribute.
If I  changed the attribute in the DC where exchange is , the replication would take less than one second.
0
 
LVL 15

Expert Comment

by:scampgb
ID: 11963666
HackLife: No worries.

Chuckbuchan:
Even though you've forced replication, it doesn't mean that the replication has completed.

Did you try it from a command-line using the info at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnw2kmag01/html/ForcingADReplication.asp ?

You can check to see what still needs to be replicated between the servers using the "showchanges" operation of repadmin

Further details on that can be found at : http://www.microsoft.com/resources/documentation/WindowsServ/2003/all/techref/en-us/Default.asp?url=/Resources/Documentation/windowsserv/2003/all/techref/en-us/repadmin_examples.asp
0
 
LVL 4

Accepted Solution

by:
HackLife earned 250 total points
ID: 11963800
First, make sure you have Support Tools in the Microsoft Windows 2000 Server Resource Kit installed on your DCs.

repadmin /syncall DC1.Yourdomain.com dc=Yourdomain,dc=com
repadmin /syncall DC2.Yourdomain.com dc=Yourdomain,dc=com
repadmin /syncall DC3.Yourdomain.com dc=Yourdomain,dc=com

If you omit the naming context, the DC replicates the forest's schema and configuration naming contexts.

repadmin /syncall DC1.Yourdomain.com /force
repadmin /syncall DC2.Yourdomain.com /force
repadmin /syncall DC3.Yourdomain.com /force

change DC1, DC2, DC3 to your DC names

change Yourdomain to your domain name.

put your commands in a .bat file and run it.

Hope this helps.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Chuckbuchan
ID: 11964434
To Hacklife: Is this needs to be saved as a batch file and ran from a DC?
0
 
LVL 4

Expert Comment

by:HackLife
ID: 11964679
the first was a vb script... which ends with .vbs

you can put command promt type commands in a batch file (end with .bat) and run it....

create a batch like:

repadmin /syncall DC1.Yourdomain.com dc=Yourdomain,dc=com /force
pause

and when you run it, it'll bring up a command prompt and run the commands.

A working example would be: (getinfo.bat)

arp -a
ipconfig /all
net view
pause


Just put the repadmin commands in a bat, change the domain, and dn to yours and run the bat. Just make sure you installed the support tools because the command does not exist if you didn't.
0
 

Author Comment

by:Chuckbuchan
ID: 11965325
well, as I said the first script didn't work .

As for the second, could you be more specific. you said save it as a batch file then run it from command prompt, it's kind of confusing.

0
 
LVL 4

Expert Comment

by:HackLife
ID: 11965602
ok.

create a new text file on your desktop.

place this in it:
repadmin /syncall dc1.Yourdomain.com dc=Yourdomain,dc=com /force
repadmin /syncall dc2.Yourdomain.com dc=Yourdomain,dc=com /force
repadmin /syncall dc3.Yourdomain.com dc=Yourdomain,dc=com /force
repadmin /syncall dc4.Yourdomain.com dc=Yourdomain,dc=com /force
pause

modify dc1.Yourdomain.com to match yours
modify dc=Yourdomain to match yours

do the same with dc2, and dc3, and dc4

run the batch on the system that you want update, because it pulls updates from other DCs.

0
 
LVL 4

Expert Comment

by:HackLife
ID: 11965609
oh, and change the text file to a batch file.
0
 
LVL 4

Expert Comment

by:HackLife
ID: 11965646
You can run: repadmin /showreps

and this can give you some information for the batch file.
0
 
LVL 4

Expert Comment

by:HackLife
ID: 11968454
The batch should work. I performed serveral test runs.

The only thing is that you cannot push replication to other DCs because Active Directory cannot work that way. You can, however, run that script on every system (run it by remote desktop if you want) and it will pull the replication from other DCs.

If you would like, I can send you my batch file I use for my network. It will look like the batch script i listed above, but with my domain and DN information in it.
0
 
LVL 4

Expert Comment

by:HackLife
ID: 11976632
No offense, but I don't understand why everytime I assist Chuckbuchan, the question gets deleted. I think I helped supply a scripted method of replication. Since he didn't get the vbs script to work, i supplied a batch version. If there is any discrepencies, if he could post so I can further assist him.
0
 
LVL 4

Expert Comment

by:HackLife
ID: 11976644
PAQ/refund please.
0
 
LVL 15

Expert Comment

by:scampgb
ID: 11977114
NetMinder: I agree with HackLife.  I think he posted a good answer to the question.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Lets look at the default installation and configuration of FreeProxy 4.10 REQUIREMENTS 1. FreeProxy 4.10 Application - Can be downloaded here (http://www.handcraftedsoftware.org/index.php?page=download) 2. Ensure that you disable the windows fi…
Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now