This article has not been completed yet. However, it may already contain helpful Information and therefore it has been published at this  stage.

Prerequisites:

  • working Domain
  • 2 x Server (Windows Server 2016)

Installing DFS -  Management Tools:

Install-WindowsFeature -Name RSAT-DFS-Mgmt-Con -IncludeManagementTools

Preparing Infrastructure:

# Vars to change
## <Server1>
## <Server2>
## <Domain>


# Pepare Disk on Server 1
Invoke-Command -ComputerName '<Server1>' -ScriptBlock {
   Get-Disk
   Initialize-Disk -Number 1
   New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter S
   Format-Volume -DriveLetter S -FileSystem NTFS
}

# Prepare Disk on Server 2
Invoke-Command -ComputerName '<Server2>' -ScriptBlock {
   Get-Disk
   Initialize-Disk -Number 1
   New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter S
   Format-Volume -DriveLetter S -FileSystem NTFS
}

# Setting up required Folders
New-Item -Type Directory -Path '\\<Server1>\S$\Root'
New-Item -Type Directory -Path '\\<Server1>\S$\Data'
New-Item -Type Directory -Path '\\<Server2>\S$\Data'

# Setting up required SMB - Shares on Server 1 + Installing needed DFS - Features
Invoke-Command -ComputerName '<Server1>' -ScriptBlock {
	New-SmbShare -Name Root -Path 'S:\Root' -ChangeAccess 'Users' -FullAccess 'Administrators'
	New-SmbShare -Name Data -Path 'S:\Data' -ChangeAccess 'Users' -FullAccess 'Administrators'
	Install-WindowsFeature -Name FS-DFS-Namespace -IncludeManagementTools -IncludeAllSubFeature
	Install-WindowsFeature -Name FS-DFS-Replication -IncludeManagementTools -IncludeAllSubFeature
}

# Setting up required SMB - Shares on Server 2 + Installing needed DFS - Features
Invoke-Command -ComputerName '<Server2>' -ScriptBlock {
	New-SmbShare -Name Data -Path 'S:\Data' -ChangeAccess 'Users' -FullAccess 'Administrators'
	Install-WindowsFeature -Name FS-DFS-Namespace -IncludeManagementTools -IncludeAllSubFeature
	Install-WindowsFeature -Name FS-DFS-Replication -IncludeManagementTools -IncludeAllSubFeature
}

# Setting up the required DFS - Shares
New-DfsnRoot -TargetPath '\\<Server1>\Root' -Type DomainV2 -Path '\\<Domain>\Root'
New-DfsnFolder -Path '\\<Domain>\Root\Data' -TargetPath '\\<Server1>\Data' -Description 'Data folder'
New-DfsnFolderTarget -Path '\\<Domain>\Root\Data' -TargetPath '\\<Server2>\Data'

# Setting up a Replication Group
New-DfsReplicationGroup -GroupName 'Branch1' | New-DfsReplicatedFolder -FolderName 'Data' | Add-DfsrMember -ComputerName '<Server1>','<Server2>'

# Enabling the Replication
Add-DfsrConnection -GroupName 'Branch1' -SourceComputerName '<Server1>' -DestinationComputerName '<Server2>'

Set-DfsrMembership -GroupName 'Branch1' -FolderName 'Data' -ContentPath 'S:\Data' -ComputerName '<Server1>' -PrimaryMember $True -Force

Set-DfsrMembership -GroupName 'Branch1' -FolderName 'Data' -ContentPath 'S:\Data' -ComputerName '<Server2>' -Force

References:

AZ-800-Administering-Windows-Server-Hybrid-Core-Infrastructure/LAB_10_Implementing_Azure_File_Sync.md at master · MicrosoftLearning/AZ-800-Administering-Windows-Server-Hybrid-Core-Infrastructure
AZ-800. Contribute to MicrosoftLearning/AZ-800-Administering-Windows-Server-Hybrid-Core-Infrastructure development by creating an account on GitHub.