none
Script to disable automatic updates in Server 2016 RRS feed

  • Question

  • Hi,

    I work for an MSP and have discovered an issue that has been well covered in other threads here, namely the Automatic Update setting in Server 2016's group policy.  The following fix appears to work when applied on a single machine:

    Gpedit.msc

      =>Computer configuration

        =>Administrative Templates

          =>Windows Components

            =>Windows Update

              =>Configure Automatic Updates

                => Check the Disabled box.

    My problem is that our various clients have a total of almost 300 Server 2016 machines (both physical and virtual) and I require a solution that allows me to make this change via a batch or Powershell script that can be pushed out via our RMM system.

    Wednesday, April 10, 2019 8:58 AM

All replies

  • Hi 

    Please use the below script

    Get-Content C:\servers.txt | ForEach-Object {
        $service = Get-WmiObject Win32_Service -Filter 'Name="wuauserv"' -ComputerName $_ -Ea 0
    	if ($service)
    	{
    		if ($service.StartMode -ne "Disabled")
    		{
    			$result = $service.ChangeStartMode("Disabled").ReturnValue
    			if($result)
    			{
    				"Failed to disable the 'wuauserv' service on $_. The return value was $result."
    			}
    			else {"Success to disable the 'wuauserv' service on $_."}
    			
    			if ($service.State -eq "Running")
    			{
    				$result = $service.StopService().ReturnValue
    				if ($result)
    				{
    					"Failed to stop the 'wuauserv' service on $_. The return value was $result."
    				}
    				else {"Success to stop the 'wuauserv' service on $_."}
    			}
    		}
    		else {"The 'wuauserv' service on $_ is already disabled."}
    	}
    	else {"Failed to retrieve the service 'wuauserv' from $_."}
    }
    

    Regards,

    Ramabadran Vasudevan

    Please don't forget to mark Propose as answer, to help others who have the same issue.


    Wednesday, April 10, 2019 9:03 AM
  • gallery.technet.microsoft.com is a repository for thousands of user-submitted scripts.  Though you may not find an exact script for your particular need, you are likely to find something that can be modified for your needs.  For example, https://gallery.technet.microsoft.com/a3a2cbcd-4dfd-4ed9-97a6-385963b24e65 is a script that is used to configure the Windows Update setting.

    If you have questions about writing/debugging/using scripts, you should ask the scripting experts in their own forum.  It is located at https://social.technet.microsoft.com/Forums/en-US/home?forum=ITCG


    tim

    Wednesday, April 10, 2019 1:28 PM
  • Hi,

     

    Thanks for posting in our forum!

     

    Please understand that our forum doesn't write scripts on users' demand. If you have your own script and run into some problems you can post it and we'd like to do the troubleshooting.

     

    You can use the script provided by Ramabadran Vasudevan, or you can find pre-written scripts here:

    https://gallery.technet.microsoft.com/scriptcenter/

     

    If you can't find what you want and can't write your own content, you can apply for scripts here:

    https://gallery.technet.microsoft.com/scriptcenter/site/requests

     

    In addition, if you have any question about PS script, you can seek the help from our PS experts in our  PS forum.

     

    PS forum:

    https://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=winserverpowershell

     

    Hope this information can help you, if you have any question, please feel free to let me know.


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Thursday, April 11, 2019 5:53 AM
    Moderator
  • Hi,

    Was your issue solved?

    If yes, would you like to share your solution in order that other community members could find the helpful reply quickly.

    If no, please reply and tell us the current situation in order to provide further help.

    Best


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, April 17, 2019 9:48 AM
    Moderator