Recipe 9.10. Working with a Specific Server's Replica ListProblemYou want to manipulate the replica list on an individual server; this manipulation might include:
SolutionUsing a graphical user interfaceTo add or remove replicas, do the following:
To see which replicas a server contains, do the following:
To export the list of replicas from a server, do the following:
Using VBScript' This code finds all replicas on a server. ' ------ SCRIPT CONFIGURATION ------ strComputerName = "<serverName>" ' e.g., "cyclone" ' ------ END CONFIGURATION --------- strE2K3WMIQuery = "winmgmts://" & strComputerName &_ "/root/MicrosoftExchangeV2" ' Get all the public folders in the MAPI TLH. ' For each folder, check to see if it has a local replica. Set folderList = GetObject(strE2K3WMIQuery).InstancesOf( _ "Exchange_PublicFolder") WScript.Echo "Folders on server " & strComputerName folderCount = 0 For each Exchange_PublicFolder in folderList if (true = Exchange_PublicFolder.HasLocalReplica) then WScript.Echo " + " & Exchange_PublicFolder.Name folderCount = folderCount + 1 end if Next WScript.Echo " " & folderCount & " folders total." If you want to make a given server into a public folder server, this script will force the server to have replicas of all public folders in the MAPI TLH (provided the server already has a public folder database on it: ' This code creates local replicas for all folders in the MAPI TLH ' ------ SCRIPT CONFIGURATION ------ strComputerName = "<serverName>" 'e.g., "CONT-EXBE01" strPubMDBPath = "<publicMDBURL>" ' ------ END CONFIGURATION --------- strE2K3WMIQuery = "winmgmts://" & strComputerName &_ "/root/MicrosoftExchangeV2" ' Get all the public folders in the MAPI TLH. ' For each folder, check to see if it has a local replica. ' If not, create one using the defined path name Set folderList = GetObject(strE2K3WMIQuery).InstancesOf(_ "Exchange_PublicFolder") WScript.Echo "Creating local replicas on server " & strComputerName For each Exchange_PublicFolder in folderList if (true = Exchange_PublicFolder.HasLocalReplica) Then WScript.Echo " - " & Exchange_PublicFolder.Name & _ ": already local" else Exchange_PublicFolder.AddReplica(strPubMDBPath) WScript.Echo " + " & Exchange_PublicFolder.Name end if Next WScript.Echo "Done creating replicas in " & strPubMDBPath & "." DiscussionBecause every server has its own local copy of the hierarchy, it's fairly straightforward to find out which folders exist; each store already knows what folders it contains, and that knowledge forms the basis of the replica list. This list is directly exposed in ESM, but to get or modify replica information from within a script, you have to either select the folders you want or iterate over all of them. There's no "replica list" object per se. Using VBScriptThe two scripts in this recipe accomplish very different tasks. The first queries for all Exchange_PublicFolder instances on the local server, which is a simple way of getting a copy of the public folder hierarchy. It then iterates over each folder in the hierarchy, printing the names of those that have local replicas. The second uses the same query to get the hierarchy, but then for any folder that does not have a local replica, it adds a local replica. This is a simple way to make a dedicated public folder server, or to create a server that contains backup copies of all your public folders. See AlsoRecipe 9.9 for finding all replicas of a specified folder |