'=======================================================================================
'
' AUTHOR: Ben Christian (www.benchristian.com)
'
' DATE: 16/03/2006
'
' COMMENT: Forces replication to the specified servers
'
'=======================================================================================
On Error Resume Next
'Create IE window for output
Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=350
objExplorer.Height = 700
objExplorer.Left = 0
objExplorer.Top = 0
Do While (objExplorer.Busy)
Wscript.Sleep 200
Loop
objExplorer.Visible = 1
'Display Initial Text in IE
objExplorer.Document.Body.InnerHTML = objExplorer.Document.Body.InnerHTML & "Scripted Replication
"
'Create IADSTools object
Dim comDLL
Set comDLL=Createobject("IADsTools.DCFunctions")
If Err.Number > 0 Then
objExplorer.Document.Body.InnerHTML = objExplorer.Document.Body.InnerHTML & "Error: You must install the Windows 2000 Server or Windows Server 2003 Support Tools Resource Kit to run this script...
"
wscript.quit
End If
'Call the replication function for each server (list the server to replicate to first, then the the source server)
Call Replicate("server2","server1")
Call Replicate("server3","server2")
Call Wait(20)
Call Replicate("server4","server3")
Call Replicate("server5","server4")
Call Wait(20)
Call Replicate("server5","server4")
Call Replicate("server4","server3")
Call Replicate("server3","server2")
'Output that replication completed successfully for all servers
objExplorer.Document.Body.InnerHTML = objExplorer.Document.Body.InnerHTML & "
Replication for all servers completed successfully.
"
Function Replicate(strDestination,strSource)
'Output starting replication
objExplorer.Document.Body.InnerHTML = objExplorer.Document.Body.InnerHTML & "Starting replication from " & strSource & " to " & strDestination & "...
"
'Start the replication
Result=comDLL.ReplicaSync(cstr(strDestination),"dc=yourdomain,dc=com",cstr(strSource))
'Output results depending on error result
If result=0 then
objExplorer.Document.Body.InnerHTML = objExplorer.Document.Body.InnerHTML & "Completed
"
else
objExplorer.Document.Body.InnerHTML = objExplorer.Document.Body.InnerHTML & "Failed.. Will not continue
"
wscript.quit
End If
End Function
Function Wait(Seconds)
WaitTime = Seconds * 1000
objExplorer.Document.Body.InnerHTML = objExplorer.Document.Body.InnerHTML & "Wait " & Seconds & " seconds...
"
wscript.sleep WaitTime
End Function