Script to set Automatically install or uninstall.. on ConfigMgr2012 clients

There was a question on Technet forum a while ago, requesting a script to configure the “Automatically install or uninstall required software and restart the computer only outside of the specified business hours”. http://social.technet.microsoft.com/Forums/en-US/configmanagerapps/thread/08d2f8e9-feaf-4143-af56-7e97ef20267c/

Torsten Meringer, ConfigMgr MVP wrote a blog post and a script a while back on how to modify the Business Hours using a vbscript, it can be found here http://www.mssccmfaq.de/2012/03/26/software-center-business-hours-auslesen-setzen/

I used Torsten’s excellent script and modified it to change the “Automatically install or uninstall….” setting instead. I will post it here if anyone else need to configure that setting.

Automatically_install

Here is a script to check what the setting is:

Set objUX = GetObject("winmgmts:\\.\root\ccm\ClientSDK:CCM_ClientUXSettings")
Set GBH = objUX.ExecMethod_("GetAutoInstallRequiredSoftwaretoNonBusinessHours")
WScript.echo "Automatically install or uninstall required software and restart the computer only outside of the specified business hours : " & GBH.AutomaticallyInstallSoftware

Set objUX = GetObject("winmgmts:\\.\root\ccm\ClientSDK:CCM_ClientUXSettings")

Set GBH = objUX.ExecMethod_("GetAutoInstallRequiredSoftwaretoNonBusinessHours")

WScript.echo "Automatically install or uninstall required software and restart the computer only outside of the specified business hours : " & GBH.AutomaticallyInstallSoftware

Here is a script to enable the “Automatically install or uninstall required software and restart the computer only outside of the specified business hours” setting.

Set objUX = GetObject("winmgmts:\\.\root\ccm\ClientSDK:CCM_ClientUXSettings")

Set inParam = objUX.Methods_.Item("SetAutoInstallRequiredSoftwaretoNonBusinessHours").inParameters.SpawnInstance_()

inParam.AutomaticallyInstallSoftware = "True"

Set result = objUX.ExecMethod_("SetAutoInstallRequiredSoftwaretoNonBusinessHours", inParam)



Thanks to Torsten who wrote the original script!!

6 Comments

Add a Comment

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