Setting "Specify settings for optional component installation and component repair" through PowerShell

John Ezzat 0 Reputation points
2024-04-18T14:55:42.09+00:00

I am trying to set the value of this local policy to "Enabled" and as well "Download repair content and optional features directly from Windows Update instead of Windows Server Update Services WSUS". The target is to set these values through the PowerShell

Failed Trials

I followed most of the articles that suggested adding the two keys (LocalSourcePath and RepairContentServerSource) under this path in the registry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Servicing"

I monitored the registry and noticed there is a key "Group Policy Objects" created only when you open the Edit Group Policy mmc in this path "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion*" and a subtree gets created under it "{Random_GUID}Machine\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing*". Under the Servicing key there are entries added for "LocalSourcePath", "RepairContentServerSource" and "**del.UseWindowsUpdate" get created and set. I tried automating the opening "Edit Group Policy" and setting the values in the dynamic key that gets created. When checking the screen the values will show to be set but once I close the console and reopen the values get lost.

I set the values through the Edit Policy Group console and compared the registry keys before and after and yet didn't find one useful key related to such a change.

My target is to automate this setting to ensure the installation of the 3.5 framework which doesn't get installed with the latest delivered Windows 11 versions after applying the latest updates. With this setting the rest of my automated scripts for configuring the 3.5 Windows feature will work.

Appreciate your support

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,069 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,891 Reputation points Microsoft Vendor
    2024-04-19T02:55:52.6366667+00:00

    Hi John Ezzat,

    Per my test on Windows 11, the group policy settings are saved in %systemroot%\System32\GroupPolicy\Machine\Registry.pol. They are loaded into the registry under "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects" when the Group Policy Editor starts and deleted when the Group Policy Editor is closed, so you may modify the Registry.pol directly or overwriting it with a template file. Make sure you back up the file before modifying it.

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments