我可以使用Powershell在Windows Server 2008 R2中configuration本地组策略设置

在Windows服务器2008 R2中,为这个手动过程

打开运行> gpedit.msc>计算机configuration> windows模板> windows update>指定intranet microsoft update服务位置> https://www.10.101.10.10.com

也应该启用/禁用状态

我可以知道如何使用PowerShell,如脚本?


这些设置在registry部分,是问:

  • 在GPMC中,展开计算机configuration,展开策略,展开pipe理模板,展开Windows组件,然后单击Windows更新。

  • 在“Windows更新”详细信息窗格中,双击“指定Intranet Microsoft更新服务位置”。

  • 单击“启用”,然后在“设置Intranet更新服务以检测更新”和“设置Intranet统计服务器”文本框中input服务器,键入WSUS服务器的相同URL。 例如,在两个框中键入http://XX.XX.XX.XX (其中servername是WSUS服务器的名称)。

这是从PowerShell脚本POssible结束?

该策略使用多个值更新了以下registry项:

HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate\AU Name: UseWUServer Type: DWORD Value: 1 Name: WUServer Type: String Value: "URL to Windows Update Server" Name: WUStatusServer Type: String Value: "URL to Intranet Statistics Server" 

只需使用Set-ItemProperty cmdlet设置这些值:

 # Set the values as needed $WindowsUpdateRegKey = "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" $WSUSServer = "https://10.101.10.10:5830" $StatServer = "https://10.101.10.10:5830" $Enabled = 1 # Test if the Registry Key doesn't exist already if(-not (Test-Path $WindowsUpdateRegKey)) { # Create the WindowsUpdate\AU key, since it doesn't exist already # The -Force parameter will create any non-existing parent keys recursively New-Item -Path $WindowsUpdateRegKey -Force } # Enable an Intranet-specific WSUS server Set-ItemProperty -Path $WindowsUpdateRegKey -Name UseWUServer -Value $Enabled -Type DWord # Specify the WSUS server Set-ItemProperty -Path $WindowsUpdateRegKey -Name WUServer -Value $WSUSServer -Type String # Specify the Statistics server Set-ItemProperty -Path $WindowsUpdateRegKey -Name WUStatusServer -Value $StatServer -Type String 

您可能必须重新启动自动更新服务才能使更改生效

 Restart-Service wuauserv -Force 

你提到“本地政策”,然后谈论“组策略”。

用于操作组策略的Powershellfunction是有限的。 您可以创build新的GPO,将GPO链接到OU,在GPO上设置权限和inheritance,并且可以设置基于registry的GPO规则。

我还没有尝试过,但是你可以将Mathias的答案和Set-GPRegistryValue结合起来。

该脚本几乎是正确的,我将其更改为WUServer和WUStatusServerpath需要在父键。

例:

 # Set the values as needed $WindowsUpdateRegKey = "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" $WindowsUpdateRootRegKey = "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\" $WSUSServer = "http://1.1.1.1:5830" $StatServer = "http://1.1.1.1.80:5830" $Enabled = 1 # Test if the Registry Key doesn't exist already if(-not (Test-Path $WindowsUpdateRegKey)) { # Create the WindowsUpdate\AU key, since it doesn't exist already # The -Force parameter will create any non-existing parent keys recursively New-Item -Path $WindowsUpdateRegKey -Force } # Enable an Intranet-specific WSUS server Set-ItemProperty -Path $WindowsUpdateRegKey -Name UseWUServer -Value $Enabled -Type DWord # Specify the WSUS server Set-ItemProperty -Path $WindowsUpdateRootRegKey -Name WUServer -Value $WSUSServer -Type String # Specify the Statistics server Set-ItemProperty -Path $WindowsUpdateRootRegKey -Name WUStatusServer -Value $StatServer -Type String # Restart Windows Update Service Restart-Service wuauserv -Force