如何使用脚本编辑本地组策略?

我必须为一些不在Windows域中的机器设置本地组策略设置和本地安全策略。 到现在为止,我已经通过在gpedit中手动设置键来完成该操作。 由于过渡到Windows 10我想自动化,并使用批处理或PowerShell脚本来做到这一点。 这将是非常好的,如果这可以完成没有第三方工具。

如何使用Powershell或batch file设置这些Policys?

提前感谢您的回答!

彼得

您可以在PowerShell中使用Set-ItemProperty在registry提供程序中执行此操作; 例如,要禁用Windows Update Access,您可以运行:

 Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate -Name DisableWindowsUpdateAccess -Value 1 

(HKLM:\是“Microsoft.PowerShell.Core \ Registry :: HKEY_LOCAL_MACHINE \”registry驱动器path的标准别名。)

组策略registry项的列表可以从Microsoft下载https://www.microsoft.com/en-us/download/confirmation.aspx?id=25250

PolicyFileEditor是用于pipe理本地GPO registry.pol文件的PowerShell模块。

Brandon Padgett提供了一个示例用法 :

 $RegPath = 'Software\Policies\Microsoft\Windows\Control Panel\Desktop' $RegName = 'ScreenSaverIsSecure' $RegData = '1' $RegType = 'String' Set-PolicyFileEntry -Path $UserDir -Key $RegPath -ValueName $RegName -Data $RegData -Type $RegType