Home
%3CLINGO-SUB%20id%3D%22lingo-sub-423190%22%20slang%3D%22en-US%22%3EDetails%20on%20ReadFRS.vbs%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-423190%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20TECHNET%20on%20Mar%2001%2C%202006%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3EHere%20is%20the%20sample%20VB%20code%20to%20migrate%20FRS%20configuration%20to%20DFSRadmin%20commands%20(from%20ReadFRS.vbs%20mentioned%20in%20the%20webcast).%20The%20script%20migrates%20settings%20from%20FRS%20to%20DFSR%20-%26nbsp%3Ba%20one-to-one%26nbsp%3Bmapping%20between%20FRS%20replica%20sets%20and%20DFS%20Replication%20replication%20groups.%20All%20memberships%20are%20disabled.%26nbsp%3BAfter%20verifying%20migration%2C%20you%20will%20need%20to%20stop%20FRS%2C%20enable%20DFS%20Replication%20memberships%2C%20and%20set%20one%20member%20for%20each%20replicated%20folder%20as%20the%20primary%20using%20DFSRadmin.%26nbsp%3B%20After%20you%20complete%20migration%20and%20determine%20that%20DFS%20Replication%20has%20completed%20initial%20sync%20and%20is%20in%20healthy%20condition%2C%20you%20will%20need%20to%20delete%20the%20FRS%20objects%20using%20ADSI%20edit.%26nbsp%3BA%20diagram%20of%20FRS%20objects%20in%20Active%20Directory%20is%20located%20in%20the%20%3CA%20href%3D%22http%3A%2F%2Ftechnet2.microsoft.com%2FWindowsServer%2Fen%2Flibrary%2F7636aede-a944-4765-8973-40dc1e1f2d561033.mspx%3Fmfr%3Dtrue%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20FRS%20Technical%20Reference%20%3C%2FA%3E%20.%20You'll%20need%20to%20scroll%20to%20the%20section%20titled%20%22Hierarchy%20of%20FRS%20Objects%20in%20Active%20Directory%20for%20DFS%20Replica%20Sets.%22We%20also%20recommend%20that%20you%20review%20our%20recent%20blog%20post%20on%20staging%20because%20DFS%20Replication%20does%20not%20allow%20you%20to%20set%20a%20common%20staging%20path.%20If%20you%20were%20doing%20this%20for%20multiple%20replica%20sets%20in%20FRS%2C%20you%20will%20need%20to%20do%20something%20like%20what%20is%20described%20in%20the%20staging%20blog.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Many%20thanks%20to%20Robert%20Powalka%20and%20Ram%20Natarajan%20for%20creating%20this%20sample%20code!%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3E%20Update%203-6%20%3CBR%20%2F%3E%20%3C%2FSTRONG%3E%20The%20original%20sample%20code%20we%20posted%20contained%20several%20differences%20than%20the%20code%20shown%20in%20the%20migration%20webcast.%20We've%20updated%20the%20sample%20code%20below%20to%20more%20closely%20match%20the%20one%20in%20the%20webcast.%20You%20might%20also%20need%20to%20do%20some%20manual%20reformatting%20after%20copying%2Fpasting%20this%20sample%20code.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20option%20explicit%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20const%20VER%3D%22v1.0%2016%2F12%2F2005%22%20%3CBR%20%2F%3E%20const%20APP%3D%22readFRS%22%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20const%20DFSRADMIN%3D%22%20%22%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20'change%20to%20empty%20string%20if%20you%20want%20to%20use%20DFSRADMIN%20BULK%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20dim%20oDomain%20%3CBR%20%2F%3E%20dim%20colForestDomains%20%3CBR%20%2F%3E%20dim%20colForestDomainDns%20%3CBR%20%2F%3E%20dim%20szDomainNC%20%3CBR%20%2F%3E%20dim%20szDomainNETBIOSname%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20'finally%20not%20needed%20-%20set%20just%20in%20case%20%3CBR%20%2F%3E%20dim%20szDomainRootDns%20%3CBR%20%2F%3E%20dim%20szDfsRoot%20%3CBR%20%2F%3E%20dim%20szDfsLink%20%3CBR%20%2F%3E%20dim%20szRGname%20%3CBR%20%2F%3E%20dim%20szRFname%20%3CBR%20%2F%3E%20dim%20szDfsPublishedPath%3C%2FP%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%20'do%20the%20work!%20%3CBR%20%2F%3E%20main%3C%2FP%3E%0A%20%20%3CP%3E'------------------------------%3C%2FP%3E%0A%20%20%3CP%3Esub%20main%3C%2FP%3E%0A%20%20%3CP%3EInit%20%3CBR%20%2F%3E%20ReadContentSetConfig%20%3CBR%20%2F%3E%20end%20sub%20'main%3C%2FP%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%20sub%20Init%20%3CBR%20%2F%3E%20On%20Error%20Resume%20Next%3C%2FP%3E%0A%20%20%3CP%3Edim%20objArgs%20%3CBR%20%2F%3E%20dim%20szConfigurationNC%20%3CBR%20%2F%3E%20dim%20oPartitionsContainer%20%3CBR%20%2F%3E%20dim%20oCrossRef%3C%2FP%3E%0A%20%20%3CP%3ESet%20objArgs%20%3D%20WScript.Arguments%20%3CBR%20%2F%3E%20If%20objArgs.Count%20%26lt%3B%202%20Then%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20'must%20get%20the%20name%20of%20the%20content%20set%20-%20RG%20to%20be%20%3CBR%20%2F%3E%20wscript.echo%20%22usage%3A%20%22%20%26amp%3B%20APP%20%26amp%3B%20%22%20DfsRoot%20DfsLink%22%20%3CBR%20%2F%3E%20WScript.Quit%26nbsp%3B%26nbsp%3B%20'quit%20program%20execution%20%3CBR%20%2F%3E%20end%20if%20%3CBR%20%2F%3E%20szDfsRoot%20%3D%20objArgs(0)%26nbsp%3B%20'DfsRoot%20to%20become%20RG%20%3CBR%20%2F%3E%20szDfsLink%20%3D%20objArgs(1)%26nbsp%3B%20'DfsLink%20to%20become%20RF%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Set%20oDomain%20%3D%20GetObject(%22%20%3CA%3E%20LDAP%3A%2F%2FRootDSE%20%3C%2FA%3E%20%22)%20%3CBR%20%2F%3E%20If%20Err%20%26lt%3B%26gt%3B%200%20Then%20%3CBR%20%2F%3E%20wscript.echo%20%22cannot%20connect%20to%20the%20domain%20-%20error%22%2C%20Err.Number%2C%20Err.Description%20%3CBR%20%2F%3E%20WScript.Quit%26nbsp%3B%26nbsp%3B%20'quit%20program%20execution%20%3CBR%20%2F%3E%20end%20if%20%3CBR%20%2F%3E%20szDomainNC%20%3D%20oDomain.Get(%22defaultNamingContext%22)%3C%2FP%3E%0A%20%20%3CP%3Eset%20colForestDomains%20%3D%20CreateObject(%22Scripting.Dictionary%22)%20%3CBR%20%2F%3E%20set%20colForestDomainDns%20%3D%20CreateObject(%22Scripting.Dictionary%22)%20%3CBR%20%2F%3E%20'find%20and%20store%20all%20NetBIOS%20domain%20names%20within%20the%20forest%20%3CBR%20%2F%3E%20szConfigurationNC%20%3D%20oDomain.Get(%22configurationNamingContext%22)%20%3CBR%20%2F%3E%20Set%20oPartitionsContainer%20%3D%20GetObject(%22%20%3CA%3E%20LDAP%3A%2F%2FCN%3DPartitions%20%3C%2FA%3E%20%2C%22%20%26amp%3B%20szConfigurationNC)%20%3CBR%20%2F%3E%20'%20Set%20the%20filter%20so%20that%20only%20crossRef%20objects%20are%20returned%20%3CBR%20%2F%3E%20oPartitionsContainer.Filter%20%3D%20Array(%22crossRef%22)%20%3CBR%20%2F%3E%20'find%20the%20right%20crossRef%20object%20and%20extract%20NetBIOS%20domain%20name%20-%20will%20be%20quick%20-%20we've%20got%20one%20domain%20%3CBR%20%2F%3E%20'%20we%20also%20extract%20the%20domain%20dns%20name%20%3CBR%20%2F%3E%20For%20Each%20oCrossRef%20in%20oPartitionsContainer%20%3CBR%20%2F%3E%20If%20oCrossRef.SystemFlags%20%3D%203%20Then%20%3CBR%20%2F%3E%20colForestDomains.add%20oCrossRef.nCName%2C%20oCrossRef.nETBIOSName%20%3CBR%20%2F%3E%20colForestDomainDns.add%20oCrossRef.nCName%2C%20oCrossRef.dnsRoot%20%3CBR%20%2F%3E%20if%20oCrossRef.nCName%20%3D%20szDomainNC%20then%20%3CBR%20%2F%3E%20szDomainNETBIOSname%20%3D%20oCrossRef.nETBIOSName%20%3CBR%20%2F%3E%20szDomainRootDns%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3D%20oCrossRef.dnsRoot%20%3CBR%20%2F%3E%20end%20if%20%3CBR%20%2F%3E%20End%20If%20%3CBR%20%2F%3E%20Next%3C%2FP%3E%0A%20%20%3CP%3Eend%20sub%20'Init%3C%2FP%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%20sub%20ReadContentSetConfig%20%3CBR%20%2F%3E%20On%20Error%20Resume%20Next%3C%2FP%3E%0A%20%20%3CP%3Econst%20DFSVolumes%3D%22CN%3DDFS%20Volumes%2CCN%3DFile%20Replication%20Service%2CCN%3DSystem%22%20%3CBR%20%2F%3E%20dim%20oRG%20%3CBR%20%2F%3E%20dim%20oRF%3C%2FP%3E%0A%20%20%3CP%3ESet%20oRG%20%3D%20GetObject(%22%20%3CA%3E%20LDAP%3A%2F%2Fcn%20%3C%2FA%3E%20%3D%22%20%26amp%3B%20szDfsRoot%20%26amp%3B%20%22%2C%22%20%26amp%3B%20DFSVolumes%20%26amp%3B%20%22%2C%22%20%26amp%3B%20szDomainNC)%20%3CBR%20%2F%3E%20if%20Err%20%26lt%3B%26gt%3B%200%20then%20%3CBR%20%2F%3E%20wscript.echo%20%22cannot%20read%20information%20from%20AD%20on%20the%20DFS%20Root%20object%22%2C%20szDfsRoot%20%3CBR%20%2F%3E%20wscript.Quit%20%3CBR%20%2F%3E%20end%20if%3C%2FP%3E%0A%20%20%3CP%3Eset%20oRF%20%3D%20GetObject(%22%20%3CA%3E%20LDAP%3A%2F%2Fcn%20%3C%2FA%3E%20%3D%22%20%26amp%3B%20szDfsRoot%20%26amp%3B%20%22%7C%22%20%26amp%3B%20szDfsLink%20%26amp%3B%20%22%2Ccn%3D%22%20%26amp%3B%20szDfsRoot%20%26amp%3B%20%22%2C%22%20%26amp%3B%20DFSVolumes%20%26amp%3B%20%22%2C%22%20%26amp%3B%20szDomainNC)%20%3CBR%20%2F%3E%20if%20Err%20%26lt%3B%26gt%3B%200%20then%20%3CBR%20%2F%3E%20wscript.echo%20%22cannot%20read%20information%20from%20AD%20on%20the%20DFS%20Link%20object%22%2C%20szDfsLink%20%3CBR%20%2F%3E%20wscript.Quit%20%3CBR%20%2F%3E%20end%20if%3C%2FP%3E%0A%20%20%3CP%3EszRFname%20%3D%20mid(oRF.cn%2C%20instr(oRF.cn%2C%22%7C%22)%2B1)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20'convention%2C%20plus%20get%20the%20original%20spelling%20%3CBR%20%2F%3E%20szRGname%20%3D%20oRG.cn%20%26amp%3B%20%22_%22%20%26amp%3B%20szRFname%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20'convention%2C%20also%20-%20get%20the%20original%20spelling%3C%2FP%3E%0A%20%20%3CP%3Ewscript.echo%20DFSRADMIN%20%26amp%3B%20%22RG%20New%20%2FRgName%3A%22%22%22%20%26amp%3B%20szRGname%20%26amp%3B%20%22%22%22%22%20%3CBR%20%2F%3E%20wscript.echo%20DFSRADMIN%20%26amp%3B%20%22RF%20New%20%2FRgName%3A%22%22%22%20%26amp%3B%20szRGname%20%26amp%3B%20%22%22%22%20%2FRfName%3A%22%22%22%20%26amp%3B%20szRFname%20%26amp%3B%20%22%22%22%22%20%3CBR%20%2F%3E%20szDfsPublishedPath%20%3D%20%22%5C%22%20%26amp%3B%20szDomainRootDns%20%26amp%3B%20%22%22%20%26amp%3B%20oRG.cn%20%26amp%3B%20%22%22%20%26amp%3B%20szRFname%20%3CBR%20%2F%3E%20wscript.echo%20DFSRADMIN%20%26amp%3B%20%22RF%20Set%20%2FRgName%3A%22%22%22%20%26amp%3B%20szRGname%20%26amp%3B%20%22%22%22%20%2FRfName%3A%22%22%22%20%26amp%3B%20szRFname%20%26amp%3B%20_%20%3CBR%20%2F%3E%20%22%22%22%20%2FRfDfsPath%3A%22%22%22%20%26amp%3B%20szDfsPublishedPath%20%26amp%3B%20%22%22%22%20%2FForce%22%3C%2FP%3E%0A%20%20%3CP%3EOn%20Error%20Goto%200%20%3CBR%20%2F%3E%20ProcessReplicatedFolder(oRF)%3C%2FP%3E%0A%20%20%3CP%3Eend%20sub%20'ReadContentSetConfig%3C%2FP%3E%0A%20%20%3CP%3E'%20Get%20the%20DFS%20Target%20Share%20for%20the%20given%20link%20on%20%3CBR%20%2F%3E%20'%20the%20given%20server%20using%20WMI%20%3CBR%20%2F%3E%20Function%20GetShareNameForLink(szLinkName%2C%20szServer)%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Dim%20objWmiService%20%3CBR%20%2F%3E%20Dim%20szQueryString%20%3CBR%20%2F%3E%20Dim%20objResultSet%20%3CBR%20%2F%3E%20Dim%20objTarget%3C%2FP%3E%0A%20%20%3CP%3ESet%20objWmiService%20%3D%20GetObject(%22winmgmts%3A%5C.rootcimv2%22)%20%3CBR%20%2F%3E%20szQueryString%20%3D%20%22Select%20*%20From%20Win32_DfsTarget%20Where%20LinkName%20Like%20'%25%5C%22%20%26amp%3B%20_%20%3CBR%20%2F%3E%20szDfsRoot%20%26amp%3B%20%22%5C%22%20%26amp%3B%20szLinkName%20%26amp%3B%20%22'%22%20%26amp%3B%20_%20%3CBR%20%2F%3E%20%22%20And%20ServerName%20Like'%22%20%26amp%3B%20szServer%20%26amp%3B%20%22%25'%22%3C%2FP%3E%0A%20%20%3CP%3ESet%20objResultSet%20%3D%20objWmiService.ExecQuery(szQueryString)%3C%2FP%3E%0A%20%20%3CP%3EIf%20(%20IsNull(objResultSet)%20Or%20objResultSet.Count%20%3D%200%20)%20Then%20%3CBR%20%2F%3E%20WScript.StdErr.WriteLine%20%22Error%20getting%20target%20share%20path%20for%20%22%20%26amp%3B%20szLinkName%20%26amp%3B%20%22%20on%20%22%20%26amp%3B%20szServer%20%3CBR%20%2F%3E%20GetShareNameForLink%20%3D%20%22%22%20%3CBR%20%2F%3E%20Exit%20Function%20%3CBR%20%2F%3E%20End%20If%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20For%20Each%20objTarget%20In%20objResultSet%20%3CBR%20%2F%3E%20GetShareNameForLink%20%3D%20objTarget.ShareName%20%3CBR%20%2F%3E%20Exit%20Function%20%3CBR%20%2F%3E%20Next%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20End%20Function%3C%2FP%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%20sub%20ProcessReplicatedFolder(obj)%3C%2FP%3E%0A%20%20%3CP%3Edim%20colRgMembers%20%3CBR%20%2F%3E%20dim%20colRfMembers%20%3CBR%20%2F%3E%20dim%20oMbr%20%3CBR%20%2F%3E%20dim%20szMbr%20%3CBR%20%2F%3E%20dim%20oConn%20%3CBR%20%2F%3E%20dim%20oComputer%20%3CBR%20%2F%3E%20dim%20strConn%20%3CBR%20%2F%3E%20dim%20szFileFilter%2C%20szDirFilter%20%3CBR%20%2F%3E%20dim%20oSubscriber%20%3CBR%20%2F%3E%20dim%20szComputerDomainFQDN%20%3CBR%20%2F%3E%20dim%20szDfsFolderPath%20%3CBR%20%2F%3E%20dim%20szShareName%20%3CBR%20%2F%3E%20dim%20blPrimarySet%3C%2FP%3E%0A%20%20%3CP%3EblPrimarySet%20%3D%20False%20%3CBR%20%2F%3E%20if%20not%20isempty(obj.fRSFileFilter)%20then%20%3CBR%20%2F%3E%20szFileFilter%20%3D%20obj.fRSFileFilter%20%3CBR%20%2F%3E%20wscript.echo%20DFSRADMIN%20%26amp%3B%20%22RF%20Set%20%2FRgName%3A%22%22%22%20%26amp%3B%20szRGname%20%26amp%3B%20%22%22%22%20%2FRfName%3A%22%22%22%20%26amp%3B%20szRFname%20%26amp%3B%20_%20%3CBR%20%2F%3E%20%22%22%22%20%2FRfFileFilter%3A%22%22%22%20%26amp%3B%20szFileFilter%20%26amp%3B%20%22%22%22%22%20%3CBR%20%2F%3E%20end%20if%20%3CBR%20%2F%3E%20if%20not%20isempty(obj.fRSDirectoryFilter)%20then%20%3CBR%20%2F%3E%20szDirFilter%20%3D%20obj.fRSDirectoryFilter%20%3CBR%20%2F%3E%20wscript.echo%20DFSRADMIN%20%26amp%3B%20%22RF%20Set%20%2FRgName%3A%22%22%22%20%26amp%3B%20szRGname%20%26amp%3B%20%22%22%22%20%2FRfName%3A%22%22%22%20%26amp%3B%20szRFname%20%26amp%3B%20_%20%3CBR%20%2F%3E%20%22%22%22%20%2FRfDirFilter%22%22%22%20%26amp%3B%20szDirFilter%20%26amp%3B%20%22%22%22%22%20%3CBR%20%2F%3E%20end%20if%3C%2FP%3E%0A%20%20%3CP%3Eset%20colRgMembers%20%3D%20CreateObject(%22Scripting.Dictionary%22)%20%3CBR%20%2F%3E%20set%20colRfMembers%20%3D%20CreateObject(%22Scripting.Dictionary%22)%3C%2FP%3E%0A%20%20%3CP%3Eobj.Filter%20%3D%20Array(%22nTFRSMember%22)%20%3CBR%20%2F%3E%20for%20each%20oMbr%20in%20obj%20%3CBR%20%2F%3E%20colRfMembers.Add%20oMbr.distinguishedName%2C%20oMbr.fRSComputerReference%3C%2FP%3E%0A%20%20%3CP%3EszComputerDomainFQDN%20%3D%20mid(oMbr.fRSComputerReference%2Cinstr(oMbr.fRSComputerReference%2C%22DC%3D%22))%20%3CBR%20%2F%3E%20set%20oComputer%20%3D%20getObject(%22LDAP%3A%2F%2F%22%20%26amp%3B%20oMbr.fRSComputerReference)%20%3CBR%20%2F%3E%20colRgMembers.Add%20oMbr.fRSComputerReference%2C%20colForestDomains.Item(szComputerDomainFQDN)%20%26amp%3B%20%22%22%20%26amp%3B%20oComputer.cn%20%3CBR%20%2F%3E%20wscript.echo%20DFSRADMIN%20%26amp%3B%20%22Mem%20New%20%2FRgName%3A%22%22%22%20%26amp%3B%20szRGname%20%26amp%3B%20%22%22%22%20%2FMemName%3A%22%22%22%20%26amp%3B%20colRgMembers.Item(oMbr.fRSComputerReference)%20%26amp%3B%20%22%22%22%20%2FForce%22%3C%2FP%3E%0A%20%20%3CP%3Eset%20oSubscriber%20%3D%20getObject(%22LDAP%3A%2F%2F%22%20%26amp%3B%20oMbr.fRSmemberReferenceBL)%20%3CBR%20%2F%3E%20szShareName%20%3D%20GetShareNameForLink(szRFname%2C%20oComputer.cn)%20%3CBR%20%2F%3E%20szDfsFolderPath%20%3D%20%22%5C%22%20%26amp%3B%20oComputer.cn%20%26amp%3B%20%22.%22%20%26amp%3B%20colForestDomainDns.Item(szComputerDomainFQDN)%20%26amp%3B%20%22%22%20%26amp%3B%20szShareName%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20wscript.echo%20DFSRADMIN%20%26amp%3B%20%22Membership%20Set%20%2FRgName%3A%22%22%22%20%26amp%3B%20szRGname%20%26amp%3B%20%22%22%22%20%2FRfName%3A%22%22%22%20%26amp%3B%20szRFname%20%26amp%3B%20_%20%3CBR%20%2F%3E%20%22%22%22%20%2FMemName%3A%22%22%22%20%26amp%3B%20colRgMembers.Item(oMbr.fRSComputerReference)%20%26amp%3B%20%22%22%22%22%20%26amp%3B%20_%20%3CBR%20%2F%3E%20%22%20%2FLocalPath%3A%22%22%22%20%26amp%3B%20oSubscriber.fRSRootPath%20%26amp%3B%20%22%22%22%22%26nbsp%3B%20%26amp%3B%20_%20%3CBR%20%2F%3E%20%22%20%2FMembershipDFSFolder%3A%22%22%22%20%26amp%3B%20szDfsFolderPath%20%26amp%3B%20_%20%3CBR%20%2F%3E%20%22%22%22%20%2FMembershipEnabled%3AFalse%20%2FDisableDirectoryVerification%26nbsp%3B%20%2FForce%22%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20next%3C%2FP%3E%0A%20%20%3CP%3Efor%20each%20szMbr%20in%20colRfMembers.Keys%20%3CBR%20%2F%3E%20set%20oMbr%20%3D%20GetObject(%22LDAP%3A%2F%2F%22%20%26amp%3B%20szMbr)%20%3CBR%20%2F%3E%20oMbr.Filter%20%3D%20Array(%22nTDSConnection%22)%20%3CBR%20%2F%3E%20for%20each%20oConn%20in%20oMbr%20%3CBR%20%2F%3E%20strConn%20%3D%20%22%20%2FSendMem%3A%22%20%26amp%3B%20colRgMembers.Item(colRfMembers.Item(oConn.fromServer))%20%26amp%3B%20_%20%3CBR%20%2F%3E%20%22%20%2FRecvMem%3A%22%20%26amp%3B%20colRgMembers.Item(colRfMembers.Item(oMbr.distinguishedName))%20%3CBR%20%2F%3E%20wscript.echo%20DFSRADMIN%20%26amp%3B%20%22Conn%20New%20%2FRgName%3A%22%22%22%20%26amp%3B%20szRGname%20%26amp%3B%20%22%22%22%22%20%26amp%3B%20strConn%20%3CBR%20%2F%3E%20wscript.echo%20DFSRADMIN%20%26amp%3B%20%22Conn%20Set%20%2FRgName%3A%22%22%22%20%26amp%3B%20szRGname%20%26amp%3B%20%22%22%22%22%20%26amp%3B%20strConn%20%26amp%3B%20%22%20%2FConnEnabled%3Atrue%22%3C%2FP%3E%0A%20%20%3CP%3Eif%20not%20isempty(oConn.schedule)%20then%20%3CBR%20%2F%3E%20DumpSchedule%20oConn.schedule%2C%20strConn%20%3CBR%20%2F%3E%20end%20if%20%3CBR%20%2F%3E%20next%20%3CBR%20%2F%3E%20next%3C%2FP%3E%0A%20%20%3CP%3E'need%20to%20set%20the%20primary%20replica%20as%20well%20-%20obj.fRSPrimarymember%20points%20out%20to%20it%2C%20it%20has%20to%20be%20devolved%20using%20LUTs%3C%2FP%3E%0A%20%20%3CP%3Eend%20sub%20'ProcessReplicatedFolder%3C%2FP%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%20sub%20DumpSchedule(binSchedule%2CstrConnection)%3C%2FP%3E%0A%20%20%3CP%3Econst%20STARTIDX%20%3D%2021%26nbsp%3B%26nbsp%3B%20'blob%20start%20%2B%201%2C%20since%20midb%20counts%20string%20position%20from%201%20%3CBR%20%2F%3E%20dim%20aDaysOfWeek%20%3CBR%20%2F%3E%20dim%20d%2C%20h%2C%20n%20%3CBR%20%2F%3E%20dim%20strSched%20%3CBR%20%2F%3E%20dim%20aSched(187)%3C%2FP%3E%0A%20%20%3CP%3EaDaysOfWeek%20%3D%20array(%22Sunday%22%2C%20%22Monday%22%2C%20%22Tuesday%22%2C%20%22Wednesday%22%2C%20%22Thursday%22%2C%20%22Friday%22%2C%20%22Saturday%22)%20%3CBR%20%2F%3E%20'schedule%20format%20determined%20by%20analysing%20the%20blob%20-%20might%20be%20wrong%20%3CBR%20%2F%3E%20'we%20only%20run%20if%20the%20schedule%20blob%20is%20188%20bytes%20-%20otherwise%20no%20clue%20how%20to%20intepret%20it%20%3CBR%20%2F%3E%20if%20(ubound(binSchedule)%20%3D%20187)%20then%3C%2FP%3E%0A%20%20%3CP%3E'remember%20-%20the%20schedule%20is%20in%20UTC!%3C%2FP%3E%0A%20%20%3CP%3Efor%20n%20%3D%20STARTIDX%20to%20188%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20'copy%20to%20true%20array%20-%20for%20convenience%20-%20vbs%20is%20not%20very%20good%20with%20octet%20string%20data%20%3CBR%20%2F%3E%20aSched(n-STARTIDX)%20%3D%20cint(ascb(midb(binSchedule%2Cn%2C1)))%20%3CBR%20%2F%3E%20next%3C%2FP%3E%0A%20%20%3CP%3Efor%20d%20%3D%200%20to%206%20%3CBR%20%2F%3E%20if%20aSched(d%20*%2024)%20%3D%200%20then%20%3CBR%20%2F%3E%20strSched%20%3D%20%220000%22%20%3CBR%20%2F%3E%20else%20%3CBR%20%2F%3E%20strSched%20%3D%20%22ffff%22%20%3CBR%20%2F%3E%20end%20if%20%3CBR%20%2F%3E%20for%20h%20%3D%201%20to%2023%20%3CBR%20%2F%3E%20if%20aSched(d%20*%2024%20%2B%20h)%20%3D%200%20then%20%3CBR%20%2F%3E%20strSched%20%3D%20strSched%20%26amp%3B%20%22%2C0000%22%20%3CBR%20%2F%3E%20else%20%3CBR%20%2F%3E%20strSched%20%3D%20strSched%20%26amp%3B%20%22%2Cffff%22%20%3CBR%20%2F%3E%20end%20if%20%3CBR%20%2F%3E%20next%20%3CBR%20%2F%3E%20wscript.echo%20DFSRADMIN%20%26amp%3B%20%22%20Conn%20Set%20Schedule%20Custom%20%2FRgName%3A%22%22%22%20%26amp%3B%20szRGname%20%26amp%3B%20%22%22%22%20%22%20%26amp%3B%20strConnection%20%26amp%3B%20_%20%3CBR%20%2F%3E%20%22%20%2FDay%3A%22%20%26amp%3B%20aDaysOfWeek(d)%20%26amp%3B%20%22%20%2FSchedule%3A%22%20%26amp%3B%20strSched%20%3CBR%20%2F%3E%20next%20%3CBR%20%2F%3E%20wscript.echo%20DFSRADMIN%20%26amp%3B%20%22%20Conn%20Set%20%2FRgName%3A%22%22%22%20%26amp%3B%20szRGname%20%26amp%3B%20%22%22%22%20%22%20%26amp%3B%20strConnection%20%26amp%3B%20_%20%3CBR%20%2F%3E%20%22%20%2FIsScheduleInLocalTime%3AFalse%22%20%3CBR%20%2F%3E%20end%20if%20%3CBR%20%2F%3E%20end%20sub%20'DumpSchedule%20%3CBR%20%2F%3E%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-423190%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TECHNET%20on%20Mar%2001%2C%202006%20Here%20is%20the%20sample%20VB%20code%20to%20migrate%20FRS%20configuration%20to%20DFSRadmin%20commands%20(from%20ReadFRS.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-423190%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Edfs%20replication%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPages%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Not applicable
First published on TECHNET on Mar 01, 2006

Here is the sample VB code to migrate FRS configuration to DFSRadmin commands (from ReadFRS.vbs mentioned in the webcast). The script migrates settings from FRS to DFSR - a one-to-one mapping between FRS replica sets and DFS Replication replication groups. All memberships are disabled. After verifying migration, you will need to stop FRS, enable DFS Replication memberships, and set one member for each replicated folder as the primary using DFSRadmin.  After you complete migration and determine that DFS Replication has completed initial sync and is in healthy condition, you will need to delete the FRS objects using ADSI edit. A diagram of FRS objects in Active Directory is located in the FRS Technical Reference . You'll need to scroll to the section titled "Hierarchy of FRS Objects in Active Directory for DFS Replica Sets."We also recommend that you review our recent blog post on staging because DFS Replication does not allow you to set a common staging path. If you were doing this for multiple replica sets in FRS, you will need to do something like what is described in the staging blog.

Many thanks to Robert Powalka and Ram Natarajan for creating this sample code!

Update 3-6
The original sample code we posted contained several differences than the code shown in the migration webcast. We've updated the sample code below to more closely match the one in the webcast. You might also need to do some manual reformatting after copying/pasting this sample code.





option explicit

const VER="v1.0 16/12/2005"
const APP="readFRS"

const DFSRADMIN=" "     'change to empty string if you want to use DFSRADMIN BULK

dim oDomain
dim colForestDomains
dim colForestDomainDns
dim szDomainNC
dim szDomainNETBIOSname       'finally not needed - set just in case
dim szDomainRootDns
dim szDfsRoot
dim szDfsLink
dim szRGname
dim szRFname
dim szDfsPublishedPath


'do the work!
main

'------------------------------

sub main

Init
ReadContentSetConfig
end sub 'main


sub Init
On Error Resume Next

dim objArgs
dim szConfigurationNC
dim oPartitionsContainer
dim oCrossRef

Set objArgs = WScript.Arguments
If objArgs.Count < 2 Then            'must get the name of the content set - RG to be
wscript.echo "usage: " & APP & " DfsRoot DfsLink"
WScript.Quit   'quit program execution
end if
szDfsRoot = objArgs(0)  'DfsRoot to become RG
szDfsLink = objArgs(1)  'DfsLink to become RF

Set oDomain = GetObject(" LDAP://RootDSE ")
If Err <> 0 Then
wscript.echo "cannot connect to the domain - error", Err.Number, Err.Description
WScript.Quit   'quit program execution
end if
szDomainNC = oDomain.Get("defaultNamingContext")

set colForestDomains = CreateObject("Scripting.Dictionary")
set colForestDomainDns = CreateObject("Scripting.Dictionary")
'find and store all NetBIOS domain names within the forest
szConfigurationNC = oDomain.Get("configurationNamingContext")
Set oPartitionsContainer = GetObject(" LDAP://CN=Partitions ," & szConfigurationNC)
' Set the filter so that only crossRef objects are returned
oPartitionsContainer.Filter = Array("crossRef")
'find the right crossRef object and extract NetBIOS domain name - will be quick - we've got one domain
' we also extract the domain dns name
For Each oCrossRef in oPartitionsContainer
If oCrossRef.SystemFlags = 3 Then
colForestDomains.add oCrossRef.nCName, oCrossRef.nETBIOSName
colForestDomainDns.add oCrossRef.nCName, oCrossRef.dnsRoot
if oCrossRef.nCName = szDomainNC then
szDomainNETBIOSname = oCrossRef.nETBIOSName
szDomainRootDns     = oCrossRef.dnsRoot
end if
End If
Next

end sub 'Init


sub ReadContentSetConfig
On Error Resume Next

const DFSVolumes="CN=DFS Volumes,CN=File Replication Service,CN=System"
dim oRG
dim oRF

Set oRG = GetObject(" LDAP://cn =" & szDfsRoot & "," & DFSVolumes & "," & szDomainNC)
if Err <> 0 then
wscript.echo "cannot read information from AD on the DFS Root object", szDfsRoot
wscript.Quit
end if

set oRF = GetObject(" LDAP://cn =" & szDfsRoot & "|" & szDfsLink & ",cn=" & szDfsRoot & "," & DFSVolumes & "," & szDomainNC)
if Err <> 0 then
wscript.echo "cannot read information from AD on the DFS Link object", szDfsLink
wscript.Quit
end if

szRFname = mid(oRF.cn, instr(oRF.cn,"|")+1)     'convention, plus get the original spelling
szRGname = oRG.cn & "_" & szRFname              'convention, also - get the original spelling

wscript.echo DFSRADMIN & "RG New /RgName:""" & szRGname & """"
wscript.echo DFSRADMIN & "RF New /RgName:""" & szRGname & """ /RfName:""" & szRFname & """"
szDfsPublishedPath = "\" & szDomainRootDns & "" & oRG.cn & "" & szRFname
wscript.echo DFSRADMIN & "RF Set /RgName:""" & szRGname & """ /RfName:""" & szRFname & _
""" /RfDfsPath:""" & szDfsPublishedPath & """ /Force"

On Error Goto 0
ProcessReplicatedFolder(oRF)

end sub 'ReadContentSetConfig

' Get the DFS Target Share for the given link on
' the given server using WMI
Function GetShareNameForLink(szLinkName, szServer)

Dim objWmiService
Dim szQueryString
Dim objResultSet
Dim objTarget

Set objWmiService = GetObject("winmgmts:\.rootcimv2")
szQueryString = "Select * From Win32_DfsTarget Where LinkName Like '%\" & _
szDfsRoot & "\" & szLinkName & "'" & _
" And ServerName Like'" & szServer & "%'"

Set objResultSet = objWmiService.ExecQuery(szQueryString)

If ( IsNull(objResultSet) Or objResultSet.Count = 0 ) Then
WScript.StdErr.WriteLine "Error getting target share path for " & szLinkName & " on " & szServer
GetShareNameForLink = ""
Exit Function
End If

For Each objTarget In objResultSet
GetShareNameForLink = objTarget.ShareName
Exit Function
Next

End Function


sub ProcessReplicatedFolder(obj)

dim colRgMembers
dim colRfMembers
dim oMbr
dim szMbr
dim oConn
dim oComputer
dim strConn
dim szFileFilter, szDirFilter
dim oSubscriber
dim szComputerDomainFQDN
dim szDfsFolderPath
dim szShareName
dim blPrimarySet

blPrimarySet = False
if not isempty(obj.fRSFileFilter) then
szFileFilter = obj.fRSFileFilter
wscript.echo DFSRADMIN & "RF Set /RgName:""" & szRGname & """ /RfName:""" & szRFname & _
""" /RfFileFilter:""" & szFileFilter & """"
end if
if not isempty(obj.fRSDirectoryFilter) then
szDirFilter = obj.fRSDirectoryFilter
wscript.echo DFSRADMIN & "RF Set /RgName:""" & szRGname & """ /RfName:""" & szRFname & _
""" /RfDirFilter""" & szDirFilter & """"
end if

set colRgMembers = CreateObject("Scripting.Dictionary")
set colRfMembers = CreateObject("Scripting.Dictionary")

obj.Filter = Array("nTFRSMember")
for each oMbr in obj
colRfMembers.Add oMbr.distinguishedName, oMbr.fRSComputerReference

szComputerDomainFQDN = mid(oMbr.fRSComputerReference,instr(oMbr.fRSComputerReference,"DC="))
set oComputer = getObject("LDAP://" & oMbr.fRSComputerReference)
colRgMembers.Add oMbr.fRSComputerReference, colForestDomains.Item(szComputerDomainFQDN) & "" & oComputer.cn
wscript.echo DFSRADMIN & "Mem New /RgName:""" & szRGname & """ /MemName:""" & colRgMembers.Item(oMbr.fRSComputerReference) & """ /Force"

set oSubscriber = getObject("LDAP://" & oMbr.fRSmemberReferenceBL)
szShareName = GetShareNameForLink(szRFname, oComputer.cn)
szDfsFolderPath = "\" & oComputer.cn & "." & colForestDomainDns.Item(szComputerDomainFQDN) & "" & szShareName

wscript.echo DFSRADMIN & "Membership Set /RgName:""" & szRGname & """ /RfName:""" & szRFname & _
""" /MemName:""" & colRgMembers.Item(oMbr.fRSComputerReference) & """" & _
" /LocalPath:""" & oSubscriber.fRSRootPath & """"  & _
" /MembershipDFSFolder:""" & szDfsFolderPath & _
""" /MembershipEnabled:False /DisableDirectoryVerification  /Force"

next

for each szMbr in colRfMembers.Keys
set oMbr = GetObject("LDAP://" & szMbr)
oMbr.Filter = Array("nTDSConnection")
for each oConn in oMbr
strConn = " /SendMem:" & colRgMembers.Item(colRfMembers.Item(oConn.fromServer)) & _
" /RecvMem:" & colRgMembers.Item(colRfMembers.Item(oMbr.distinguishedName))
wscript.echo DFSRADMIN & "Conn New /RgName:""" & szRGname & """" & strConn
wscript.echo DFSRADMIN & "Conn Set /RgName:""" & szRGname & """" & strConn & " /ConnEnabled:true"

if not isempty(oConn.schedule) then
DumpSchedule oConn.schedule, strConn
end if
next
next

'need to set the primary replica as well - obj.fRSPrimarymember points out to it, it has to be devolved using LUTs

end sub 'ProcessReplicatedFolder


sub DumpSchedule(binSchedule,strConnection)

const STARTIDX = 21   'blob start + 1, since midb counts string position from 1
dim aDaysOfWeek
dim d, h, n
dim strSched
dim aSched(187)

aDaysOfWeek = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
'schedule format determined by analysing the blob - might be wrong
'we only run if the schedule blob is 188 bytes - otherwise no clue how to intepret it
if (ubound(binSchedule) = 187) then

'remember - the schedule is in UTC!

for n = STARTIDX to 188      'copy to true array - for convenience - vbs is not very good with octet string data
aSched(n-STARTIDX) = cint(ascb(midb(binSchedule,n,1)))
next

for d = 0 to 6
if aSched(d * 24) = 0 then
strSched = "0000"
else
strSched = "ffff"
end if
for h = 1 to 23
if aSched(d * 24 + h) = 0 then
strSched = strSched & ",0000"
else
strSched = strSched & ",ffff"
end if
next
wscript.echo DFSRADMIN & " Conn Set Schedule Custom /RgName:""" & szRGname & """ " & strConnection & _
" /Day:" & aDaysOfWeek(d) & " /Schedule:" & strSched
next
wscript.echo DFSRADMIN & " Conn Set /RgName:""" & szRGname & """ " & strConnection & _
" /IsScheduleInLocalTime:False"
end if
end sub 'DumpSchedule