combine several AccessRules into one single one - ACL of User Object in Active Directory

Wolfgang-2637 0 Reputation points
2023-08-16T10:59:21.27+00:00

Hi,

I want to set a new ACL for one specific AD Group to an OU. This works fine but my solution now generates for each "New-Obejct..." one seperate AccessRule. That's logical but I don't want this.

The main code looks like this:

$ACL = Get-Acl -Path $TargetOU

$RuleLockoutTime = New-Object System.DirectoryServices.ActiveDirectoryAccessRule ($GroupSID,"WriteProperty","Allow",$GUID_1,"Descendents",$User)
$RuleResetPassword = New-Object System.DirectoryServices.ActiveDirectoryAccessRule ($GroupSID,"ExtendedRight","Allow",$GUID_2","Descendents",$User)
$Rule....... = New-Object System.DirectoryServices.ActiveDirectoryAccessRule (........

$ACL.AddAccessRule($RuleLockoutTime)
$ACL.AddAccessRule($RuleResetPassword)
$ACL.AddAccessRule($Rule......

Set-Acl -Path $TargetOU -AclObject $ACL

How can I put all together in one single AcccesRule? I already tried a lot but I never reached the right syntax.

Thanks in advance,

Wolfgang

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,940 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,917 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.