Recipe 9.4. Forcing Public Folder ReplicationProblemYou've made changes to a public folder and you want those changes immediately replicated. SolutionUsing a graphical user interfaceTo force replication of a folder, do the following:
Using VBScript' This code sends the contents of all public folders on the specified ' server to any other servers that have those folders in their replica list. ' ------ SCRIPT CONFIGURATION ------ strComputerName = "<serverName>" ' ------ END CONFIGURATION --------- strE2K3WMIQuery = "winmgmts://" & strComputerName &_ "/root/MicrosoftExchangeV2" Set folderList = GetObject(strE2K3WMIQuery).InstancesOf("Exchange_PublicFolder") ' Get the replica count. For any folder that has multiple replicas, ' force the replica *on this server* to request any changes that it ' knows of but hasn't gotten. For each Exchange_PublicFolder in folderList replicaCount = UBound(Exchange_PublicFolder.ReplicaList)+1 WScript.Echo "Folder " & Exchange_PublicFolder.Name & " has " & _ replicaCount & " replicas." If (replicaCount > 1) Then WScript.Echo " Synchronizing " & Exchange_PublicFolder.Path Exchange_PublicFolder.Synchronize End If Next WScript.Echo "Done processing folders." If you don't want to force replication of all folders on a server, you can use the same method to replicate an individual folder: ' This code forces replication of the contents of a specified folder. ' ------ SCRIPT CONFIGURATION ------ strComputerName = "<serverName>" strPubFolderPath = "<folderPath>" ' e.g., "/Book Suggestions/" ' ------ END CONFIGURATION --------- strE2K3WMIQuery = "winmgmts://" & strComputerName &_ "/root/MicrosoftExchangeV2" ' query for the specific folder we want Set wmiService = GetObject(strE2K3WMIQuery) query = "Select * From Exchange_PublicFolder" & " Where Path='" & _ strPubFolderPath & "'" Set targetFolder = wmiService.ExecQuery(query) ' if we have multiple replicas, send changes from the first ' replica to all others For Each folder In targetFolder replicaCount = UBound(folder.ReplicaList)+1 WScript.Echo "Folder " & folder.Name & " has " & replicaCount & _ " replicas." If (replicaCount > 1) then WScript.Echo " Sending changes from " & folder.Path _ & " to " & folder.ReplicaList(0) folder.SendChanges 30, folder.ReplicaList Folder.Put_ End If Next WScript.Echo "Done processing folders." DiscussionIn normal operation, Exchange will replicate public folder contents without any help or intervention from you. However, there may be times when replication isn't working fast enough, in which case, you can force replicated updates to be sent or requested. Using a graphical user interfaceFrom ESM, you can send contents from a selected replica to one or more target replicas; any changes to the source in the time window you specify are packaged as replication messages and sent using the normal mechanism. Using VBScriptThe two scripts in this recipe show two different approaches. The first one uses the Synchronize() method, which tells Exchange to request the actual content for any update it doesn't yet have. This works because the folder may have a list of content updates (or, more precisely, change numbers) for which it hasn't actually gotten the changes. Synchronize( ) just brings the two into harmony by requesting content backfills for the change numbers whose content isn't present yet. The second script uses SendChanges() , which allows you to force updated content from one replica to be sent to other, specified, replicas. In this case, the script sends changes from the first replica of the "Book Suggestions" folder to all other replicas. Because the ordering of replicas may change between folders on different servers, this script could be enhanced by having it check to see which replicas the changed content is being sent to. See AlsoRecipe 9.5 for replicating the public folder hierarchy, Recipe 9.10 for working with a server's replica list, Recipe 9.13 for controlling replication settings, and MSDN: WMI Exchange_PublicFolder class |