DFS-R is the replication component of the Distributed File System (DFS). Windows Server 2012R2 introduces powershell cmdlets that can be used for management rather thsn relying on the old dfsutil commands.
Some of the common issues with DFS-R are files not replicating due to network latency or connectivity issues. The knock on effect leads to staging folders becoming full leading and file replication stopping.
If you dont have SCOM or other monitoring tools at hand to monitor DFS-R. The code below can be saved as a ps1 poweshell script and scheduled to run on one of the DFS-R servers. The script generates a healthcheck report and sends the report by email.
Amend the variables at the start to define replication group and email server/recipent/sender details.
Additonal DFS servers can be specified by extending the Write-DfsrHealthReport command by adding the “$DFSservers[..]” variable with array index value.
$DFSGroupName ="Enter DFS Replication group name here" $DFSservers = (Get-DfsrMembership -GroupName $DFSGroupName |select -ExpandProperty computername) $foldernamedate = $(get-date -f dd-MM-yyyy) $source = "C:\DFSReportsImport\" $destination = "C:\DFSReportsExport\$foldernamedate\DFS_Report.zip" $emailServer = "mysmtpserver.example.com" $sender = "email@example.com" $recipients = "firstname.lastname@example.org" mkdir c:\DFSReportsImport\$foldernamedate mkdir c:\DFSReportsExport\$foldernamedate Write-DfsrHealthReport -GroupName $DFSGroupName -ReferenceComputerName $DFSservers -MemberComputerName $DFSservers, $DFSservers -CountFiles -Path c:\DFSReportsImport\$foldernamedate\ Add-Type -assembly "system.io.compression.filesystem" [io.compression.zipfile]::CreateFromDirectory($source, $destination) remove-item -path c:\DFSReportsImport\$foldernamedate -Recurse -Force send-mailmessage -from $sender -to $recipients -subject "DFS Report $foldernamedate" -Body "DFS Report generated from $DFSservers" -smtpserver $EmailServer -attachments "C:\DFSReportsExport\$foldernamedate\DFS_Report.zip" remove-item -path c:\DFSReportsExport\$foldernamedate -Recurse -Force