I want to create a group in AD that has the permission to create group objects and edit group objects in a specific Organization Unit.

Anonymous
2023-11-09T18:25:19+00:00

I want to create a group in AD that has the permission to create group objects and edit group objects in a specific Organizational Unit.

I made a script that is able to do this. I created a group that can create object and edit them, but it isn't restricted to Group objects only. How can I add this feature?

I was able to do that with the dsa for testing, but I need to do it using a script.

ps1 script:

$OrganizationalUnit = "OU=TargetOUGroups, (...)"

$GroupName = "GroupManager"

if (-not (Get-ADGroup -Filter {Name -eq $GroupName})) {

    New-ADGroup -Name $GroupName -GroupCategory Security -GroupScope Global -Path $OrganizationalUnit

}

Set-Location AD:

$Group = Get-ADGroup -Identity $GroupName

$GroupSID = $Group.SID

$ACL = Get-Acl -Path "AD:$OrganizationalUnit"

$Identity = New-Object System.Security.Principal.SecurityIdentifier($GroupSID)

$ADRights = @("WriteProperty", "CreateChild")

$Type = [System.Security.AccessControl.AccessControlType]::Allow

$InheritanceType = [System.DirectoryServices.ActiveDirectorySecurityInheritance]::All

foreach ($ADRight in $ADRights) {

    $ADRightType = [System.DirectoryServices.ActiveDirectoryRights]$ADRight

    $Rule = New-Object System.DirectoryServices.ActiveDirectoryAccessRule($Identity, $ADRightType, $Type, $InheritanceType)

    $ACL.AddAccessRule($Rule)

}

Set-Acl -Path "AD:$OrganizationalUnit" -AclObject $ACL

Windows for business | Windows Server | User experience | PowerShell

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.

0 comments No comments
{count} votes
Accepted answer
  1. Anonymous
    2023-11-10T08:12:54+00:00

    Hi iggodinho,

    You can specify the object type to which the access rule applies.

    $objectType =[guid]"bf967a9c-0de6-11d0-a285-00aa003049e2" 
    
    $Rule = New-Object System.DirectoryServices.ActiveDirectoryAccessRule ($Identity, $ADRightType, $Type, $objectType, $InheritanceType)
    

    bf967a9c-0de6-11d0-a285-00aa003049e2 is the schema GUID of the group object.

    Best Regards,

    Ian Xue

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2023-11-10T17:43:50+00:00

    Thank you very much for the help.

    It worked.

    I would like to do this for other objects. Where can I get the schema GUID for other object types? Such as user or OU

    0 comments No comments