Skip to content

DFSReplicationGroupMember

dscbot edited this page Feb 14, 2024 · 2 revisions

DFSReplicationGroupMember

Parameters

Parameter Attribute DataType Description Allowed Values
GroupName Key String The name of the DFS Replication Group.
Ensure Write String Specifies whether the DFS Replication Group member should exist. Present, Absent
ComputerName Key String The computer name of the Replication Group member. This can be specified using either the ComputerName or FQDN name for the member. If an FQDN name is used and the DomainName parameter is set, the FQDN domain name must match.
Description Write String A description for the DFS Replication Group member.
DomainName Write String The name of the AD Domain the DFS Replication Group this replication group is in.

Description

This resource is used to create, edit or remove Replication Group Members. It can be used to add members to a Replication Group individually. These may alternatively be defined at group creation via the DFSReplicationGroup Members parameter - NB do NOT use both methods in the same configuration to avoid config flapping.

Examples

Example 1

Create a DFS Replication Group called Public containing two members, FileServer1 and FileServer2. The Replication Group contains a single folder called Software. A description will be set on the Software folder and it will be set to exclude the directory Temp from replication. Create a two-way connection between the two nodes.

Configuration DFSReplicationGroupMember_Simple_Config
{
    param
    (
        [Parameter()]
        [PSCredential]
        $Credential
    )

    Import-DscResource -Module DFSDsc

    Node localhost
    {
        <#
            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
        DFSReplicationGroup RGPublic
        {
            GroupName = 'Public'
            Description = 'Public files for use by all departments'
            # NB Members parameter must NOT be defined to allow DFSReplicationGroupMember to be used elsewhere - avoid configuration flapping
            Ensure = 'Present'
            Folders = 'Software'
            PSDSCRunAsCredential = $Credential
            DependsOn = '[WindowsFeature]RSATDFSMgmtConInstall'
        } # End of RGPublic Resource

        DFSReplicationGroupMember RGPublicMemberFS1
        {
            GroupName = 'Public'
            ComputerName = 'FileServer1'
            Ensure = 'Present'
            PSDSCRunAsCredential = $Credential
            DependsOn = '[DFSReplicationGroup]RGPublic'
        } # End of RGPublicMemberFS1 Resource

        DFSReplicationGroupMember RGPublicMemberFS2
        {
            GroupName = 'Public'
            ComputerName = 'FileServer2'
            Ensure = 'Present'
            PSDSCRunAsCredential = $Credential
            DependsOn = '[DFSReplicationGroup]RGPublic'
        } # End of RGPublicMemberFS2 Resource

        DFSReplicationGroupFolder RGSoftwareFolder
        {
            GroupName = 'Public'
            FolderName = 'Software'
            Description = 'DFS Share for storing software installers'
            DirectoryNameToExclude = 'Temp'
            PSDSCRunAsCredential = $Credential
            DependsOn = '[DFSReplicationGroup]RGPublic'
        } # End of RGPublic Resource

        DFSReplicationGroupMembership RGPublicSoftwareFS1
        {
            GroupName = 'Public'
            FolderName = 'Software'
            ComputerName = 'FileServer1'
            ContentPath = 'd:\Public\Software'
            StagingPathQuotaInMB = 4096
            PrimaryMember = $true
            PSDSCRunAsCredential = $Credential
            DependsOn = '[DFSReplicationGroupMember]RGPublicMemberFS1', '[DFSReplicationGroupFolder]RGSoftwareFolder'
        } # End of RGPublicSoftwareFS1 Resource

        DFSReplicationGroupMembership RGPublicSoftwareFS2
        {
            GroupName = 'Public'
            FolderName = 'Software'
            ComputerName = 'FileServer2'
            ContentPath = 'e:\Data\Public\Software'
            StagingPathQuotaInMB = 4096
            PSDSCRunAsCredential = $Credential
            DependsOn = '[DFSReplicationGroupMember]RGPublicMemberFS2', '[DFSReplicationGroupFolder]RGSoftwareFolder'
        } # End of RGPublicSoftwareFS2 Resource

        DFSReplicationGroupConnection RGPublicConnectionFS1
        {
            GroupName = 'Public'
            Ensure = 'Present'
            SourceComputerName = 'FileServer1'
            DestinationComputerName = 'FileServer2'
            PSDSCRunAsCredential = $Credential
            DependsOn = '[DFSReplicationGroupFolder]RGSoftwareFolder'
        } # End of RGPublicConnectionFS1 Resource
    } # End of Node
} # End of Configuration