Sep 6, 2017

DFSR Replication Schedules with PowerShell

The other day one I had to tune DFS replication schedules. No big problem but too much clicking if you have tens or maybe hundreds of replication groups. How to make sure each replication group has correct schedule? With PowerShell, of cource.

Bandwith details in the GUI might look like this

Schedule gone baad

 Each block in the GUI is one hour. Block coloring has three variants in which partially colored means Bandwith usage is "something else than No Replication or Full", somewhere between 16Kbps and 256Mbps.

So it was time to do some PowerShell and fix these replication schedules without pain.





PowerShell has a module DFSR with 45 different cmdlets, the two we're now interested in are Get-DfsrGroupSchedule and Set-DfsrGroupSchedule.

As bandwith is limited and I had 20+ replication groups doing their stuff, things started to slow down as DFSR saturated the WAN connection. I decided to go the easy way here so I set the same schedule for all of my replication groups, after the initial replication has finished I'll tune these schedules up to higher values but now 256Kbps is enough, this will use approx 5Mbps of my 10Mbps.

Below is the script that I ran. Things started to flow smoothly when the receiving DFS service picked up new shedule, you can speed up this by replicating AD connecitons and running gpupdate (/force).

Cheers,

Ari


# Each slot is 15min, four slots in one hour, from 00:00 - 24:00, total of 96 slots
# Bandwith: F = Full, 4 = 256Kbps
# https://technet.microsoft.com/fi-fi/itpro/powershell/windows/dfsr/set-dfsrgroupschedule
$fullSched = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$slowSched = "FFFFFFFFFFFFFFFFFFFFFFFF4444444444444444444444444444444444444444444444444444444444444444FFFFFFFF"

# "FFFFFFFFFFFFFFFFFFFFFFFF".length/4 = 6 hours, from midnight to 6am
# "FFFFFFFFFFFFFFFFFFFFFFFF4444444444444444444444444444444444444444444444444444444444444444".length/4 = 22, until 10pm
 
 

# save old schedule
 
 
Get-DfsrGroupSchedule | select GroupName,BandwidthDetail | fl | Out-File -FilePath C:\temp\rgscheds-2017-09-06.txt

# get all schedules and modify
$groupSched = Get-DfsrGroupSchedule | select GroupName
foreach ($g in $groupSched) {
Set-DfsrGroupSchedule -GroupName $g.GroupName -Day Monday,Tuesday,Wednesday,Thursday,Friday -BandwidthDetail $slowSched
Set-DfsrGroupSchedule -GroupName $g.GroupName -Day Saturday,Sunday -BandwidthDetail $fullSched
}