在组策略编辑器的用户配置文件中配置“不要在用户注销时强行卸载用户注册表”

问题描述 投票:0回答:1

我需要编写一个 PowerShell 脚本,该脚本应在所有机器中配置以下组策略设置。

Gpedit.msc → 计算机配置 → 管理模板 → 系统 → 用户配置文件 → “不要在用户注销时强行卸载用户注册表” 到“已启用”。

据我所知,这也可以使用注册表值来完成

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System]
"DisableForceUnload"=dword:00000001

但是通过脚本,当我添加所需的注册表项时,更改并没有反映在组策略控制台中。当然,我需要使用组策略 cmdlet! 当我尝试使用

Set-GPRegistryValue
和以下语句时

Set-GPRegistryValue -Name "User Profiles" `
  -key "HKLM\SOFTWARE\Policies\Microsoft\Windows\System\" `
  -ValueName DisableForceUnload -Type DWord -Value 1

它显示异常说“从服务器返回了推荐。”

Set-GPRegistryValue : A referral was returned from the server. (Exception from HRESULT: 0x8007202B)
At D:\Work\XYZ\Desktop\GPO1.ps1:6 char:1
+ Set-GPRegistryValue -Name "User Profiles" -key "HKLM\SOF ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-GPRegistryValue], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.GroupPolicy.Commands.SetGPRegistryValue 
   Command

我到底错过了什么?

powershell powershell-3.0 powershell-remoting user-profile group-policy
1个回答
0
投票

返回 referral 的域控制器意味着该对象存在于目录中,但不在该特定域控制器上。例如,分区目录或受信任/子域可能会发生这种情况。

您可以使用

-Domain
-Server
参数连接到特定域和/或服务器。默认是连接当前用户域的PDC模拟器

© www.soinside.com 2019 - 2024. All rights reserved.