将GPO链接到用户

时间:2019-02-28 13:50:38

标签: powershell active-directory group-policy

我编写了一个代码,允许我将GPO链接到OU,但是我想更具体一些,并将其链接到已知用户。

下面是我编写的代码:

Import-Module ActiveDirectory
Import-Module GroupPolicy
$GPOName = 'DisableInternet'
$GPO = New-GPO -Name $GPOName -Domain 'Administrateur.6NLG-AD'
Set-GPPrefRegistryValue -Name $GPOName -Context User -Key 'HKCU\Software\Policies\Microsoft\Internet Explorer\Restrictions' -ValueName 'NoBrowserOptions' -Value 1 -Type DWord -Action Create
Set-GPPrefRegistryValue -Name $GPOName -Context User -Key 'HKCU\Software\Policies\Microsoft\Internet Explorer\Restrictions' -ValueName 'NoBrowserOptions' -Value 1 -Type DWord -Action Update
Set-GPPrefRegistryValue -Name $GPOName -Context User -Key 'HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -ValueName ProxyServer -Value 0.0.0.0:80 -Type String -Action Create
Set-GPPrefRegistryValue -Name $GPOName -Context User -Key 'HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -ValueName ProxyEnable -Value 1 -Type DWord -Action Create
Set-GPPrefRegistryValue -Name $GPOName -Context User -Key 'HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -ValueName ProxyServer -Value 0.0.0.0:80 -Type String -Action Update
Set-GPPrefRegistryValue -Name $GPOName -Context User -Key 'HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -ValueName ProxyEnable -Value 1 -Type DWord -Action Update
New-GPLink -Name $GPOName -Target 'OU=Nouvelle_UO,DC=Administrateur,DC=6NLG-AD'

1 个答案:

答案 0 :(得分:0)

您不能将GPO链接到用户,只能链接到OU。但是,您可以使用权限过滤GPO,因此它仅适用于特定的用户或组。

因此,请使用New-GPLink将GPO链接到用户帐户所在的OU。或者在继承级别上,该继承将允许GPO应用于用户OU。

您需要从GPO中删除Authenticated UsersDomain Users之类的其他广泛组织。

您可以通过查看GPO来检查这些组,例如,在下面的屏幕快照中,可以在安全过滤部分下看到,默认的Authenticated Users拥有对GPO:

enter image description here

在为用户添加权限之前,您需要从安全过滤中删除该组:

Set-GPPermission -TargetName "Domain\Authenticated Users" -TargetType Group -PermissionLevel None -Replace

然后将GPO的权限设置为您希望将其应用于的用户:

Set-GPPermission -Name DisableInternet -TargetName SamAccountName -TargetType User -PermissionLevel GpoApply

有关更多信息和示例,请参见Set-GPPermission documentation