How to change registry settings for automatic updates using reusable powershell script

Carter James 1 Reputation point
2022-09-15T21:17:51.72+00:00

I am trying to create a reusable script that will change the automatic update settings in the registry for future Windows VMs that my company creates. I want to set the Configure Automatic Updates value to enabled and set the Specify intranet Microsoft update service location to enabled, as well as setting two URLs pointing to my WSUS servers. I'm not sure how to accomplish this with a PowerShell script, as I am very new to scripting PowerShell, so if someone could lend some help or point me in the right direction, that would be greatly appreciated.

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,911 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,504 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Adam J. Marshall 9,206 Reputation points MVP
    2022-09-15T23:31:49.47+00:00

    Use this on a properly configured system

    Get-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate'  
    Get-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU'  
    

    Then use

    Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "UseWUServer" -Value 1  
      
    

    As a template to convert your settings to a PowerShell script

    1 person found this answer helpful.

  2. Adam J. Marshall 9,206 Reputation points MVP
    2022-09-15T21:21:10.79+00:00

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.