Distributed File System DSC Resource Update

After releasing the DFS DSC Resource Module yesterday, I had an idea of how to simplify it if you’re deploying a DFS folder that contains the same path content path for all members. I added a ContentPaths parameter (an array of strings) to the cDFSRepGroup resource so that if the folder exists in the same location on every member, you won’t need to use the cDFSRepGroupMembership resource to individually set the Content Path for each member.

For example:

configuration Sample_cDFSRepGroup_Simple
{
    Import-DscResource -Module cDFS

    Node $NodeName
    {
        [PSCredential]$Credential = New-Object System.Management.Automation.PSCredential ("CONTOSO.COM\Administrator", (ConvertTo-SecureString $"MyP@ssw0rd!1" -AsPlainText -Force))

        # Install the Prerequisite features first
        # Requires Windows Server 2012 R2 Full install
        WindowsFeature RSATDFSMgmtConInstall 
        { 
            Ensure = "Present" 
            Name = "RSAT-DFS-Mgmt-Con" 
        }

        # Configure the Replication Group
        cDFSRepGroup RGPublic
        {
            GroupName = 'Public'
            Description = 'Public files for use by all departments'
            Ensure = 'Present'
            Members = 'FileServer1','FileServer2'
            Folders = 'Software','Misc'
            Topology = 'Fullmesh'
            ContentPaths = 'd:\public\software','d:\public\misc'
            PSDSCRunAsCredential = $Credential
            DependsOn = "[WindowsFeature]RSATDFSMgmtConInstall"
        } # End of RGPublic Resource
    } # End of Node
} # End of Configuration

The above example creates a DFS Replication Group called Public containing two folders, Software and Misc. The DFS Replication Group replicates to two members, FileServer1 and FileServer2. It is maintaining a Fullmesh connection topology.

The thing to note is that the ContentPaths array should have the elements in a matching order to the Folders parameter. So this:

            Folders = 'Misc','Software'
            ContentPaths = 'd:\public\software','d:\public\misc'

Would result in the Misc folder being set with the Content Path d:\public\software’ and the Public folder being set with the Content Path  d:\public\misc‘ – which is probably not ideal.

The Primary Member

Every Resource Group Folder needs a Primary Member set for initial replication to take place. If you use this automatic assigning of content paths the Primary Member will automatically be set to the computer listed first in the Members parameter. If you want to change this you’ll need to use the manual cDFSRepGroupMembership resource instead.

Partially Setting Content Paths

It is actually possible to only automatically configure some of the content paths in a DFS Replication Group by leaving the appropriate ContentPaths array entry blank. This would allow you to automatically configure some folders but leave other folders to be manually configured.

For example:

        cDFSRepGroup RGPublic
        {
            GroupName = 'Public'
            Description = 'Public files for use by all departments'
            Ensure = 'Present'
            Members = 'FileServer1','FileServer2'
            Folders = 'Software','Misc','Video'
            Topology = 'Fullmesh'
            ContentPaths = 'd:\public\software','','e:\video'
            PSDSCRunAsCredential = $Credential
            DependsOn = "[WindowsFeature]RSATDFSMgmtConInstall"
        } # End of RGPublic Resource

This would create a Replication Group called Public, with three folders Software, Misc and Video. The Software and Video folders will be automatically configured with Content Paths but the Misc folder will be left unconfigured so that it can be configured manually.

Optional Use

Using the ContentPaths or Topology parameters is optional. You can still define the folder Content Paths manually using the cDFSRepGroupMembership resource and/or configure the connection topology manually using the cDFSRepGroupConnection resource if you want to.

Important: It is not recommended that you define a ContentPath for a folder in the cDFSRepGroup ContentPaths parameter if you are also setting it in a cDFSRepGroupMembership resource. The same applies to defining and automatic Topology and using the cDFSRepGroupConnection resource.

And again, in case you missed it, the post covering the original resource is here.

2 thoughts on “Distributed File System DSC Resource Update

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s