Not able to modify Local Group Policy with powershell commands

Anonymous
2024-08-31T08:06:32+00:00

Hi,

I'm trying to modify Local Group Policy on my windows machine using PowerShell commands but not able to do so in both windows 10 and windows server 2022.

As an example, I set the automatic update as below in gpedit:

Running PowerShell as Administrator, I am able to view the changes made in gpedit being reflected in local registry:

PS C:\Windows\system32> $registryPath = "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU"

PS C:\Windows\system32> Get-ItemProperty -Path $registryPath -Name "AUOptions" , "ScheduledInstallDay", "ScheduledInstallTime"



AUOptions : 3

ScheduledInstallDay : 0

ScheduledInstallTime : 17

PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate\AU

PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate

PSChildName : AU

PSDrive : HKLM

PSProvider : Microsoft.PowerShell.Core\Registry

But when I try to make changes via PowerShell commands as below, I can see the registry getting changed but not the setting in the Local GP editor:

PS C:\Windows\system32> $auOptions = 4

PS C:\Windows\system32> $scheduledInstallDay = 0

PS C:\Windows\system32> $scheduledInstallTime = 18

PS C:\Windows\system32> Set-ItemProperty -Path $registryPath -Name "AUOptions" -Value $auOptions -Type DWord

>> Set-ItemProperty -Path $registryPath -Name "ScheduledInstallDay" -Value $scheduledInstallDay -Type DWord

>> Set-ItemProperty -Path $registryPath -Name "ScheduledInstallTime" -Value $scheduledInstallTime -Type DWord

PS C:\Windows\system32> Get-ItemProperty -Path $registryPath -Name "AUOptions" , "ScheduledInstallDay", "ScheduledInstallTime"



AUOptions : 4

ScheduledInstallDay : 0

ScheduledInstallTime : 18

PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate\AU

PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate

PSChildName : AU

PSDrive : HKLM

PSProvider : Microsoft.PowerShell.Core\Registry

Tried to force update the gp and also restarted windows, but still the latest changes I made via commands are only saved to registry and not the local group policy.

PS C:\Windows\system32> gpupdate /Force

Updating policy...


Computer Policy update has completed successfully.

User Policy update has completed successfully.

I would appreciate it if you could advise a solution to this issue. Thanks

Windows for home | Windows 10 | Settings

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-09-01T09:56:28+00:00

    Dear Iman_Y,

    Thank you for reaching out to the Microsoft Community.

    I understand how challenging it can be to manage Local Group Policy settings through PowerShell, especially when the changes do not reflect as expected in the Local Group Policy Editor (gpedit.msc). This issue can indeed be intricate, and I’m here to assist you in navigating the best possible approach to resolve it.

    From your detailed description, it appears that while you have successfully modified the relevant registry keys associated with Windows Update settings, these changes are not being reflected in the Local Group Policy Editor. This discrepancy arises because the Local Group Policy Editor directly manages Group Policy Objects (GPOs), and these GPO settings may not immediately sync with registry changes, particularly when alterations are made outside of the traditional policy management tools.

    To ensure you receive the most accurate and specialized guidance, I recommend posting your question on Windows 10 - Microsoft Q&A, where a broader community of users and experts frequently discuss similar topics. You can easily navigate to the 'Ask a question' section, where professionals who specialize in Group Policy and PowerShell can provide more tailored solutions to your issue. Additionally, you may find the forums on Microsoft Learn an invaluable resource for sharing ideas, suggesting specific solutions, and collaborating with others to solve complex problems.

    I sincerely hope that by reaching out to the appropriate channels, your concern will be addressed efficiently and to your satisfaction. Thank you for your understanding, and please feel free to return to the Microsoft Community if you have further questions or require additional assistance.

    Best Regards,

    Martin | Microsoft Community Support Specialist

    0 comments No comments