ConfigMgr: Force update Client Business Hours using Compliance

I’ve started using a Compliance policy to force the client’s business hours. The only thing I look for is that the ‘StartTime’ has been set back to 5am.

Configuration Item
Discovery script:

# Boolean
If (Get-CimClass -Namespace "root\ccm\ClientSDK" -ClassName CCM_ClientUXSettings -ErrorAction SilentlyContinue) {
	$StartTime = (Invoke-CimMethod -Namespace "root\ccm\ClientSDK" -Class CCM_ClientUXSettings -MethodName GetBusinessHours).StartTime
} Else {
	$StartTime = 8
If ($StartTime -eq 5) { return $false } else { return $true }

I use a Boolean since all I care about is that the default ‘StartTime’ isn’t set and I found out you can’t enable Remediation with a Compliance rule (integer) of “not equals.” I also double check that the class “CCM_ClientUXSettings” exists just in case so it doesn’t try remediation on a machine that would seem to be having other issues already.

Remediation script:

[uint32]$startTime = 8
[uint32]$endTime = 17
[uint32]$workingDays = 62
$return = Invoke-CimMethod -Namespace "root\ccm\ClientSDK" -Class CCM_ClientUXSettings -MethodName SetBusinessHours -Arguments @{StartTime=$StartTime;EndTime=$EndTime;WorkingDays=$WorkingDays}

The default settings I use is 8am to 5pm (Monday to Friday).

I then set the rule for compliance to equal true and run the remediation script if not.

Compliance Rule

Then put the item in a Configuration Baseline and deploy.