最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to change a group policy in Powershell persistently? - Stack Overflow

programmeradmin9浏览0评论

Currently I am trying to set the local group policy "DoNotConnectToWindowsUpdateInternetLocations" programatically using powershell, so I thought simply adding the required registry keys would be enough. However, when I set the corresponding values in the registry, and reboot my system, the values in gpedit.msc are not changed.

So I thought to additionally run gpupdate /force to force the new values but this even makes the situation worse, i.e. directly after that call, all the registry values are resoted to their value before.

This computer is not part of a domain, and no policies are set from outside. So what additional magic happens in the background that is needed to set that policy successfully?

# Enable the policy
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name "DoNotConnectToWindowsUpdateInternetLocations" -Value 1

# Set the intranet update service location
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name "UpdateServiceUrl" -Value 
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name "UpdateServiceUrlAlternate" -Value 
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name "WUServer" -Value 
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name "WUStatusServer" -Value 

#after the following call, all settings are restored to their previous values
gpupdate /force 
发布评论

评论列表(0)

  1. 暂无评论