获取并设置细粒度的 GPO 权限

获取并设置细粒度的 GPO 权限

我们正在尝试编写一个脚本来设置大量 GPO 的权限。我们遇到的问题是,我们在网上找到的所有方法都不允许设置自定义或特殊权限。以下是我们迄今为止使用过的方法,但并未产生我们需要的结果。

方法 1- XML 报告

$xmlReport = $gpo.GenerateReport('xml')

此命令仅返回受托人的名称。还包括一些我不确定是否相关的属性。

方法 2- ADSI/LDAP 对象

$GPOACLList = $GPOObjSec.GetAccessRules($true,$true,[System.Security.Principal.SecurityIdentifier])

此方法返回组和权限,但不是细粒度的。对于我知道被视为具有细粒度权限的自定义/特殊 ACL,返回的“FileSystemRights”是“FullControl”。

方法 3- 获取 GPPermission

Get-GPPermission $gpoWithAppSpec -all | select -ExpandProperty permission

返回与 Set-GPPermission 可用的权限类似的权限,例如“GpoApply”、“GpoEditDeleteModifySecurity”、“GpoRead”。同样,这些不是细粒度的权限。

答案1

这将显示在 gpo 上设置的所有 acl:

$DomainDN = (Get-ADDomain).DistinguishedName
(get-acl "ad:CN={GPO-GUID},CN=Policies,CN=System,$($DomainDN)").Access

除了 ad 对象上的 acl 之外,sysvol 文件夹中的 GPO 上还有权限:

$DnsRoot = (get-addomain).DnsRoot    
(get-acl "\\$DnsRoot\sysvol\$DnsRoot\Policies\{GPO-GUID}\").Access

最有可能的是,有办法根据 gpmc 中嵌入的 ad-object 权限自动创建 sysvol 权限,但我不知道如何访问它。

更新:我找到了如何做到这一点。

使用IGPMGPO::MakeACLConsistent

$GPOGUID = 'my-guid'
$DnsRoot = (get-addomain).DnsRoot
$gpm = New-Object -ComObject GPMgmt.GPM
$gpmconstants = $gpm.GetConstants()
$gpmdomain = $gpm.getdomain($DnsRoot, "", $gpmconstants.UsePDC)
$gpmgpo = $gpmdomain.getgpo($GPOGUID)
if (!$gpmgpo.IsACLConsistent()) {
  $gpmgpo.MakeACLConsistent()
}

相关内容