Menu
CCMEXEC.COM – Enterprise Mobility
  • Home
  • General
  • Configuration Manager
  • Windows 10
  • Intune
  • GitHub
  • Windows 11
  • About the author
CCMEXEC.COM – Enterprise Mobility

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

Posted on December 27, 2012 by Jörgen Nilsson

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 thoughts on “Script to set Automatically install or uninstall.. on ConfigMgr2012 clients”

  1. Stian Larsen says:
    March 6, 2013 at 8:28 am

    Great job, now to translate it to powershell 🙂

    Reply
  2. Pingback: Cloud Solutions Architect
  3. Martin Wüthrich says:
    June 25, 2015 at 10:09 am

    Exactly what I needed, thanks a lot 🙂

    Reply
  4. jklight says:
    August 18, 2015 at 4:05 pm

    $Return = Invoke-WmiMethod -Namespace “Root\ccm\ClientSDK” -Class CCM_ClientUXSettings -Name SetAutoInstallRequiredSoftwaretoNonBusinessHours -ArgumentList @($TRUE) -ComputerName $ComputerName -ErrorAction STOP

    Reply
  5. Rob says:
    March 16, 2017 at 1:23 pm

    Discovery Script –
    $cmClientUserSettings = [WmiClass]”\\.\ROOT\ccm\ClientSDK:CCM_ClientUXSettings”
    $nonbusinessHours = $cmClientUserSettings.GetAutoInstallRequiredSoftwaretoNonBusinessHours()
    Return $nonbusinessHours.AutomaticallyInstallSoftware

    Remediation Script –
    Invoke-WmiMethod -Namespace “Root\ccm\ClientSDK” -Class CCM_ClientUXSettings -Name SetAutoInstallRequiredSoftwaretoNonBusinessHours -ArgumentList @($TRUE)

    Reply
  6. Thomas says:
    January 13, 2018 at 1:47 am

    This doesn’t work as a detection method in SCCM because no matter the return the application is detected I need something that will return true for detection and nothing if there is no detection as false becomes true when returned.

    Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
All code is provided "AS-IS" with no warranties.

Recent Posts

  • Community tools demoed at WPNinjas 2023
  • PowerShell script to keep Personal Teams away in Windows 11
  • Windows 11 Multi-App kiosk – a first look
  • Playing around with Driver Updates in Intune
  • MMUGSE – Summer Meetup 8th of June 2023

©2023 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT