r/PowerShell•
Pr1m-e

Set-ACL Problems

Hi guys,

struggling with a little problem. I´m trying to add new a new ACL to an folder with subfolders.

Code:

$colRights = [System.Security.AccessControl.FileSystemRights]::ReadAndExecute

$InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit `
-bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit


$PropagationFlag = [System.Security.AccessControl.PropagationFlags]::None 

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

$objUser = New-Object System.Security.Principal.NTAccount($principal) 

$objACE = New-Object System.Security.AccessControl.FileSystemAccessRule `
($objUser, $colRights, $InheritanceFlag, $PropagationFlag, $objType) 

$objACL = Get-ACL $folderPath
$objACL.AddAccessRule($objACE) 


Set-ACL $folderPath $objACL 

The Problem:

some folders don´t get the new ACL although the Inheritance isn´t disabled on these folders.

If i manually add or edit the ACL on the root folder afterwards and confirm the changes-> all subfolders inherit the new ACL wich i set through the powershell command!?!?

Posted Jan 23, 2016, 4:48 PM UTC

88
KingDoink•

Sorry, I'm mobile right now and I can't check, but your propagation flag is set to none. So it's not pushing the new ACL to child objects. You might be able to get away with removing that property for now.

2
Pr1m-eOP•

could you tell me the difference between the inheritance and propagation flag? im going to test it with the propagation flag

1
Pr1m-eOP•

tested with all variations of the propagation flag -> same result

1
KingDoink•

Inherit comes from above. Propagate works its was down.

1
msemack2•

What is the ownership on the folders? Does the account you're running under have Full Control on the folders?

2
Pr1m-eOP•

sure - as i said, icacls working properly

1
jbtechwood•

I hated trying to figure out the built in ACL cmdlets. I moved to using Rhon Edwards' PowerShell Access Control Module and ACLs are no longer an issue...might want to take a look...I can do most of what your doing in just a line or two

2
Pr1m-eOP•

if i do the same with icacls there is no problem ...

1