This commit is contained in:
Philip Woolford 2020-01-20 07:37:03 -06:00 committed by GitHub
commit 36491482bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -3629,7 +3629,14 @@ function Add-ObjectAcl {
# add all the new ACEs to the specified object
ForEach ($ACE in $ACEs) {
Write-Verbose "Granting principal $ResolvedPrincipalSID '$($ACE.ObjectType)' rights on $($_.Properties.distinguishedname)"
# resolve the object
$Object = [adsi]($_.path)
# restrict object changes to ACL only
[System.DirectoryServices.DirectoryEntryConfiguration]$SecOptions = $Object.get_Options()
$SecOptions.SecurityMasks = [System.DirectoryServices.SecurityMasks]'Dacl'
# add ACE
$Object.PsBase.ObjectSecurity.AddAccessRule($ACE)
$Object.PsBase.commitchanges()
}