$GetACL = Get-Acl $Path $Access = "domain\$SamID" $Permission = [S.S.A.FileSystemRights]"Modify, Synchronize" $Inheri = [S.S.A.InheritanceFlags]"ContainerInherit, ObjectInherit" $Allpropagation = [S.S.A.PropagationFlags]"None" $AccessRule = New-Object S.S.A.FileSystemAccessRule($Access, $Permission, $Inheri, $Allpropagation, "Allow") if ($GetACL.Access | Where { $_.IdentityReference -eq $Access}) { Write-Host "Modifying Permissions For: $Access" -ForeGroundColor Yellow $AccessModification = New-Object system.security.AccessControl.AccessControlModification $AccessModification.value__ = 2 $Modification = $False $GetACL.ModifyAccessRule($AccessModification, $AccessRule, [ref]$Modification) | Out-Null } Else { Write-Host "Adding Permission: $Permission For: $Access" $GetACL.AddAccessRule($AccessRule) } Set-Acl -aclobject $GetACL -Path $Path
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)