Automating DFSN/R Setup

This topic contains 6 replies, has 4 voices, and was last updated by Profile photo of Tim Tim 3 months ago.

  • Author
    Posts
  • #28537
    Profile photo of Kreston Yates
    Kreston Yates
    Participant

    I'm trying to automate the configuration of DFSR and am having a tough time. Setup is pretty straight forward, two DC's holding the namespace and two member servers for the DFSR setup. Ive read this guy quite a few times, but I guess I'm missing something; http://blogs.technet.com/b/filecab/archive/2013/08/20/dfs-replication-in-windows-server-2012-r2-if-you-only-knew-the-power-of-the-dark-shell.aspx
    I've pulled the following download and tried the TN script, with the same results; https://gallery.technet.microsoft.com/Configure-DFSR-using-162aa873

    #create share for DFS-N
    New-Item -ItemType Directory -Path C:\DFSROOT
    New-SmbShare -Name DFSROOT -Path C:\DFSROOT -FullAccess Administrators -ReadAccess Users
    #Create namespace
    New-DfsnRoot -Path \\$DomainName\DFSROOT -TargetPath \\$DC1\DFSROOT  -Type DomainV2 -EnableSiteCosting $true
    New-DfsnRootTarget -Path \\$DomainName\DFSROOT -TargetPath \\$DC2\DFSROOT
    #Add DFS Folder for the share
    New-DfsnFolder -Path \\$DomainName\DFSROOT\Share -TargetPath \\$Memeber1\Share
    #Add Secondary server to DFS Folder share
    New-DfsnFolderTarget  -Path \\$DomainName\DFSROOT\Share -TargetPath \\$Member2\Share
    #Add Replication Group Name, folder, memebers and connections for Share
    New-DfsReplicationGroup -GroupName $DomainName\dfsroot\Share | New-DfsReplicatedFolder -FolderName Share | Add-DfsrMember -ComputerName "$Member1","$Member2"
    Add-DfsrConnection -GroupName $DomainName\dfsroot\Share -SourceComputerName $Member1 -DestinationComputerName $Member2
    Set-DfsrMembership -GroupName $DomainName\dfsroot\Share -FolderName Share -ComputerName $Member1 -ContentPath D:\Share -StagingPathQuotaInMB 20960 -ConflictAndDeletedQuotaInMB 1024 -PrimaryMember $true -Force
    Set-DfsrMembership -GroupName $DomainName\dfsroot\Share -FolderName Share -ComputerName $Member2 -ContentPath D:\Share -StagingPathQuotaInMB 20960 -ConflictAndDeletedQuotaInMB 1024 -Force
    Get-DfsrMember | Update-DfsrConfigurationFromAD
    

    so when I run the above code it does NOT error out, but when I double check by going to the DFS GUI, The Namespace folder "share" doesn't show as replicated(even though it shows in the replicated folders below the namespace, and if I try try to use the GUI to perform the same task it says the share is already being replicated). Also, the namespace doesn't list as published. The STRANGE thing is that data is replicated between the two $member servers, so does the GUI not work properly if you use powershell to setup DFSR? I've torn down and rebuilt this setup a number of times with the same results. Any help would be appreciated, this ones been eating my lunch and watching the TN radio video and reading the above articles it seems straightforward, but im clearly missing something.
    Running 2012R2 on all four servers.

  • #28543
    Profile photo of Don Jones
    Don Jones
    Keymaster

    It is entirely possible you're looking at a GUI bug. If the share is, in fact, replicating – then mission accomplished. I don't know of a workaround for that, unfortunately.

  • #28544
    Profile photo of Kreston Yates
    Kreston Yates
    Participant

    Don,

    Thanks for replying. In looking at it more this AM, if I go into the GUI after running the script, and open replication, and on the right select replicated folders, that's where it states its not published. If I highlight the folder, right click and select "share and publish in namespace" either option will tell me its not possible b/c the folder is already created or you haven't chosen to create any new shares. Now, if I delete the Namespace folder "Share" and go back through the exercise of sharing and publishing via the GUI, it creates the new "share" folder and everything shows as it should in the GUI.

    So either I'm doing something wrong, ie additional, in my script or you are correct that the GUI is not working properly.
    Its unfortunate b/c this process would be quite helpful as far as time saving, but once the environment is in the hands of a customer, they'll more than likely be using the GUI and not PS, so I have to have the GUI right as well.

    Guess I just need someone to test it and tell me I'm not crazy and that there is in fact a bug.

  • #28547
    Profile photo of Don Jones
    Don Jones
    Keymaster

    I've put it on Twitter to see if anyone else has run into it. Unfortunately I don't have a way to test it for you, or I would.

  • #28548
    Profile photo of Daniel Krebs
    Daniel Krebs
    Moderator

    You need to use the DfsnPath parameter on New-DfsReplicatedFolder or Set-DfsReplicatedFolder to connect the DFS namespace folder to the replicated folder. It won't happen without using the parameter.


    New-DfsReplicatedFolder -FolderName Share -DfsnPath \\$DomainName\DFSROOT\Share

    or

    Set-DfsReplicatedFolder -GroupName $DomainName\dfsroot\Share -DfsnPath \\$DomainName\DFSROOT\Share

  • #28558
    Profile photo of Kreston Yates
    Kreston Yates
    Participant

    Don, thanks for the assist.

    Daniel, thanks so much for making my headache go away!!! That was it!! In reading the dfsr cmdlts, I never did, or would have made the connection between this optional setting and how it would affect the GUI. Wew, thanks again!

    -DfsnPath
    Specifies the DFS Namespace (DFSN) folder path of the replicated folder.
    The DFSN folder path has no effect on replication. This property exists only as a descriptive convenience to administrators and DFS Replication service does not validate the value of this property.

  • #64327
    Profile photo of Tim
    Tim
    Participant

    Thank you Daniel. I have been working on this for a most of the day and this is the only place I found the answer. It seems the Microsoft examples on setting up a replicated DFS folder are missing this part of the command.

    My problem was when I created the replication group, the DFS folder did not have the little green arrow indicating it was replicated and when clicking on "Replicate" I got an error saying it was already replicated. The replication was also working fine. Everything was good except how it appeared in the DFS Management GUI.

    For the record this is the command that needs to be used, the bold parameters are what is missing from the examples out there that cause the problem

    New-DfsReplicationGroup -GroupName "RepGroup" | New-DfsReplicatedFolder -FolderName "DFSFolder" -GroupName "RepGroup" -DfsnPath \\company.local\DFSRoot\DFSFolder | Add-DfsrMember -ComputerName "server001","server002" | Format-Table dnsname,groupname -auto -wrap

    And finally these are the commands to create a DFS folder and replicate it between 2 servers.

    New-DfsnFolder -Path "\\company.local\DFSRoot\DFSFolder" -TargetPath "\\server001.company.local\ShareName"
    New-DfsnFolderTarget -Path "\\company.local\DFSRoot\DFSFolder" -TargetPath "\\server002.company.local\ShareName"
    New-DfsReplicationGroup -GroupName "RepGroup" | New-DfsReplicatedFolder -FolderName "DFSFolder" -GroupName "RepGroup" -DfsnPath \\company.local\DFSRoot\DFSFolder | Add-DfsrMember -ComputerName "server001","server002" | Format-Table dnsname,groupname -auto -wrap
    Add-DfsrConnection -GroupName "RepGroup" -SourceComputerName "server001" -DestinationComputerName "server002" | Format-Table *name -wrap -auto
    Set-DfsrMembership -GroupName "RepGroup" -FolderName "DFSFolder" -ContentPath "E:\ShareName" -ComputerName "server001" -PrimaryMember $True -StagingPathQuotaInMB 16384 -Force | Format-Table *name,*path,primary* -auto -wrap
    Set-DfsrMembership -GroupName "RepGroup" -FolderName "DFSFolder" -ContentPath "E:\ShareName" -ComputerName "server002" -StagingPathQuotaInMB 16384 -Force | Format-Table *name,*path,primary* -auto -wrap
    dfsrdiag syncnow /partner:server002 /RGName:RepGroup /Time:1
    

You must be logged in to reply to this topic.