Setting the new options for Peer Cache on Boundary Groups using PowerShell – Configuration Manager 1806
In the 1806 release of Configuration Manager it is now possible to configure Peer Cache options for a Boundary Group, including:
- Allowing or disabling Peer Cache for the Boundary Group, and;
- Restricting Peer Cache downloads in the Boundary Group to peers within the same subnet.
The PowerShell cmdlet for setting Boundary Group settings (Set-CMBoundaryGroup) hasn't been updated to support these options yet, however as with anything in Configuration Manager everything can be accessed and modified programmatically by using the SMS Provider.
The SMS_BoundaryGroup class in 1806 has been updated with a new Flags attribute. The values and the resulting behaviour are listed below:
- 0 - Allow peer cache downloads within this Boundary Group;
- 1 - Do not allow peer cache downloads within this Boundary Group;
- 2 - Allow peer cache downloads within this Boundary Group but restrict downloads to peers within the same subnet.
Below is some sample PowerShell code I used to set each Boundary Group in my lab to allow peer cache and restrict downloads to peers in the same subnet. Always be sure to test code before running it in a production environment. This code is provided as is with no warranties implied or otherwise. By default the script will just output the changes that would be made, you need to toggle the "testmode" attribute to get it to make changes.
#Change testmode to false to save the changes
$testmode=$true
#The Configuration Manager site code
$sitecode="B01"
#The Configuration Manager Primary Server
$SMSProvider="BLCM01"
#the flag you want to set
$newflag=2
$BoundaryGroups=get-wmiobject -Namespace root\sms\site_$sitecode -Class SMS_BoundaryGroup -computername $SMSProvider
Foreach ($BoundaryGroup in $BoundaryGroups) {
write-host "Setting $($BoundaryGroup.name) flags to $newflag (previously $($BoundaryGroup.flags))"
$BoundaryGroup.Flags = $newflag
Try {
If (-not $testmode) {
$result=$BoundaryGroup.Put()
write-host "saved" -ForegroundColor green
}
} Catch {
write-host "failed to set flag" -ForegroundColor red
}
}
It appears that "Prefer Cloud Based Sources" is 9. In order to maintain my VPN boundary groups but ensure all of the others are set correctly for internal I changed the the $BoundaryGroup variable line to this: $BoundaryGroups = (get-wmiobject -Namespace root\sms\site_$sitecode -Class SMS_BoundaryGroup -computername $SMSProvider) | Where-Object {($_.Flags -NE 2) -and ($_.Flags -le 2)}
awesome, saved me from manually updating 400 boundary groups!
Perfect!
Works like a charm ! Thx