SCCM 2012: Set Software Center Business Hours with a Compliance Configuration Item

There are basically two scenarios when business hours come in to effect in SCCM 2012:

1. A user selects to defer required application/software update installations and reboots to take place outside of business hours:

\"image\"

2. A user selects the option in the software center to have SCCM automatically install all required software and restart the computer outside of business hours:\"image\"

The default business hours are set to 05:00 – 22:00, Monday to Friday. The business hours can’t be configured through client settings, only by the user or by using the SDK or client WMI methods.

There could be several reasons why you want to change the default business hours. For example, the typical working hours of the majority of your users are different from the default settings and you have a power plan that puts machines in standby before the default business hours end, which would effectively close the window for maintenance outside business hours.

To set the business hours using Compliance settings in ConfigrMgr 2012, navigate to the Asset & Compliance Workspace, select Compliance Settings and create a new configuration item. In the Create Settings page, select a Script setting with a String data type:

\"image\"

Edit the Discovery Script and paste in the following Powershell code:

$cmClientUserSettings = [WmiClass]"\\\\.\\ROOT\\ccm\\ClientSDK:CCM_ClientUXSettings"
$businessHours = $cmClientUserSettings.GetBusinessHours()
$businessHoursCI = [string]$businessHours.StartTime + "," + [string]$businessHours.EndTime + "," + [string]$businessHours.WorkingDays
Return $businessHoursCI

This will return the current business hours as a string in this format:

7,19,62

The first digit is the start time (7am), the second digit is the end time (7pm) and the third digit is the days of the week. The days of the week are calculated using the table below, so Monday – Friday is calculated as 2+4+8+16+32 = 62.

Sunday1
Monday2
Tuesday4
Wednesday8
Thursday16
Friday32
Saturday64

Edit the Remediation Script and paste in the following code, setting the desired business hours in the variables $startTime, $endTime and $workingDays.

$startTime = 7
$endTime = 19
$workingDays = 62
$cmClientUserSettings = [WmiClass]"\\\\.\\ROOT\\ccm\\ClientSDK:CCM_ClientUXSettings"
$businessHours = $cmClientUserSettings.PSBase.GetMethodParameters("SetBusinessHours")
$businessHours.StartTime = $StartTime
$businessHours.EndTime = $EndTime
$businessHours.WorkingDays = $WorkingDays

Try {
$result = $cmClientUserSettings.PSBase.InvokeMethod("SetBusinessHours", $businessHours, $Null)
If ($result.ReturnValue -eq 0 ) {
"Success."
}
Else {
"Failed to set SCCM client business hours."
}
}
Catch {
"Failed to set SCCM client business hours."
}

Add the following compliance rule, setting the value to your desired business hours and enabling the remediation script for noncompliant clients:

\"image\"

This rule will remediate noncompliant clients to the desired business hours.

Lastly, add the configuration item to a configuration baseline and deploy to your target collection.

Now we have centrally controlled business hours in ConfigMgr 2012:

\"image\"

Further Reference:

There’s a useful post on Technet that explains the concept of Business Hours vs. Maintenance Windows in System Center 2012 Configuration Manager.

Torsten Merringer has a post here that shows how to set the business hours using VBScript.

5 thoughts on “SCCM 2012: Set Software Center Business Hours with a Compliance Configuration Item”

  1. Pingback: ConfigMgr (SCCM) 2012 – Starter kit – Very Useful Links « Anoop's | @anoopmannur

  2. Scott Ewing

    Great article. It is exactly what I need to know about changing the default business hors on a collection of SCCM 2012 clients. Thank you!

  3. Pingback: ConfigMgr 2012 / SCCM 2012 SP1 Step by Step Guide Part 15a: Software Updates Notification behaviour | MS Tech BLOG

    1. Joe Chukkas

      I ran into the same issue, solved it by setting “Powershell execution policy” to “Bypass” in the “Computer Agent” of the SCCM client settings.

      Now it works like a charm…

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top