如何使用PowerShell编辑本地组策略



在本地组策略编辑器(GUI(中,有一个名为Do not allow window animations的设置位于Computer Configuration->Administrative Templates->Windows Components->Desktop Window Manager,我想使用powershell将其设置为Enabled,由于我的windows版本是专业的,我可以将RSAT GroupPolicy功能添加到我的计算机中,现在我可以在windows powershell 中使用组策略Cmdlet

但我对如何使用命令启用该功能知之甚少

我厌倦了使用

Get-GPO -Name "Do not allow window animations"

但这会返回

Get-GPO : Current security context is not associated with an Active Directory domain or forest.

grouppolicy模块很好,但我不知道如何查询或更改GPO 中任何设置的值

如果需要cmdlet来更改值,可以使用库中的PolicyFileEditor模块https://www.powershellgallery.com/packages/PolicyFileEditor/3.0.1

Get-GPO函数专门用于域组策略,而不是您所引用的本地策略。该模块的描述也提到了这一点:

获取域中的一个GPO或所有GPO。

为了修改本地策略,您需要更改注册表中的相应设置

例如,要禁用关闭按钮,您需要修改:

HKEY_LOCAL_MACHINESOFTWAREMicrosoftPolicyManagerdefaultStartHideShutDown
Value = 1

最新更新