' This script was originally published in the Exchange Cookbook, ' (http://www.exchangebookcook.com). Written by Paul Robichaux, ' Missy Koslosky, and Devin Ganger. Redistributed with permission ' of the publisher, O'Reilly & Associates. ' This script creates a new public folder tree on the specified server. ' You also have to specify the public folder database, admin group, ' org name, and domain. ' ------ SCRIPT CONFIGURATION ------ strServerName = "" ' e.g. "BATMAN" strPFDBName = "" strPFTreeName = "" strAdminGroup = " strOrgName = "" strDomain = "" ' e.g. "dc=contoso,dc=local" ' ------ END CONFIGURATION --------- Set theServer = CreateObject("CDOEXM.ExchangeServer") Set theNewTree = CreateObject("CDOEXM.FolderTree") Set theDSE = GetObject("LDAP://RootDSE") Set thePFDB = CreateObject("CDOEXM.PublicStoreDB") ' create the public tree. You could dynamically get the AG and org ' name but for simplicity we're defining them statically strTreeURL = "LDAP://CN=" & strPFTreeName & ",CN=Folder Hierarchies" & _ ",CN=" & strAdminGroup & ",CN=Administrative Groups,CN=" & strOrgName & _ ",CN=Microsoft Exchange,CN=Services,CN=Configuration," & theDSE.Get("defaultnamingcontext") theNewTree.name = strPFTreeName theNewTree.DataSource.SaveTo strTreeURL thePFDB.Name = strPFDBName thePFDB.FolderTree = strTreeURL ' Find the first SG theServer.DataSource.Open strServerName For Each sg In theServer.StorageGroups theFirstSG = sg Exit for Next ' Create the URL to the new PF, then create and mount it strPFURL = "LDAP://" & theServer.DirectoryServer & "/CN=" & strPFDBName & "," & theFirstSG thePFDB.DataSource.SaveTo strPFURL thePFDB.Mount WScript.Echo " created new PF tree at " & strPFURL