Perform comprehensive testing to ensure DFS-R is working correctly and troubleshoot any issues.
Test file creation and replication:
# Create test files on primary server
$testFile = "D:\ReplicatedData\replication-test-$(Get-Date -Format 'yyyyMMdd-HHmmss').txt"
Set-Content -Path $testFile -Value "Test file created on SERVER01 at $(Get-Date)"
# Wait 30 seconds then check if file appears on secondary servers
Start-Sleep -Seconds 30
Invoke-Command -ComputerName "SERVER02" -ScriptBlock { Get-ChildItem "D:\ReplicatedData\replication-test*.txt" | Select-Object Name, LastWriteTime }
Check replication health and backlog:
# Check replication health
Get-DfsrState -ComputerName "SERVER01", "SERVER02" | Format-Table ComputerName, State, LastError
# Check for any pending files in backlog
Get-DfsrBacklog -SourceComputerName "SERVER01" -DestinationComputerName "SERVER02" -FolderName "ReplicatedData"
Monitor replication performance:
# Get replication statistics
Get-DfsrFileHash -Path "D:\ReplicatedData" -ComputerName "SERVER01", "SERVER02" | Compare-Object -Property Hash -IncludeEqual
Test conflict resolution (for multidirectional setups):
# Create same filename on two servers simultaneously
Invoke-Command -ComputerName "SERVER01" -ScriptBlock { Set-Content "D:\SharedData\conflict-test.txt" "Content from SERVER01" }
Invoke-Command -ComputerName "SERVER02" -ScriptBlock { Set-Content "D:\SharedData\conflict-test.txt" "Content from SERVER02" }
# Check conflict resolution after 60 seconds
Start-Sleep -Seconds 60
Get-ChildItem "D:\SharedData\*conflict*" -Recurse
Pro tip: Use Get-DfsrBacklog regularly to monitor replication health. A consistently growing backlog indicates performance issues or connectivity problems.
Verify Event Logs for successful replication:
# Check for successful replication events
Get-WinEvent -FilterHashtable @{LogName='DFS Replication'; ID=4104,4614} -MaxEvents 5 | Format-Table TimeCreated, Id, Message
Event ID 4104 indicates successful initial synchronization, while 4614 shows successful file replication. Any error events (Warning or Error level) should be investigated immediately.