cNtfsAccessControl icon indicating copy to clipboard operation
cNtfsAccessControl copied to clipboard

NoPropagateInherit is not boolean but can be 0, 1 or 2

Open TorstenSchnitter opened this issue 3 years ago • 1 comments

Setting ace to 'ReadAndExecute' with 'SubfoldersOnly' and 'NoPropagateInherit' = $true does not end in the correct result. ACE in 'PropagationFlags' should be 'NoPropagateInherit, InheritOnly' but is 'NoPropagateInherit' only witch is not the correct result. (the problem may be in File 'cNtfsPermissionEntry.psm1' at starting line 739)

cNtfsPermissionEntry ('[{0}]:Users' -f $Path) { Ensure = 'Present' Path = $Path Principal = ('BUILTIN\Users') AccessControlInformation = @( cNtfsAccessControlInformation { AccessControlType = 'Allow' FileSystemRights = 'ReadAndExecute', 'Synchronize' Inheritance = 'SubFoldersOnly' NoPropagateInherit = $true } ) }

should result in: FileSystemRights AccessControlType IdentityReference IsInherited InheritanceFlags PropagationFlags ---------------- ----------------- ----------------- ----------- ---------------- ---------------- ReadAndExecute, Synchronize Allow BUILTIN\Users False ContainerInherit NoPropagateInherit, InheritOnly

but really results in: FileSystemRights AccessControlType IdentityReference IsInherited InheritanceFlags PropagationFlags ---------------- ----------------- ----------------- ----------- ---------------- ---------------- ReadAndExecute, Synchronize Allow BUILTIN\Users False ContainerInherit NoPropagateInherit

TorstenSchnitter avatar Sep 14 '22 11:09 TorstenSchnitter

function New-FileSystemAccessRule should be changed at line 739 from: if ($NoPropagateInherit -eq $true -and $InheritanceFlags -ne 'None') { [System.Security.AccessControl.PropagationFlags]$PropagationFlags = 'NoPropagateInherit' }

To: if ($NoPropagateInherit -eq $true -and $InheritanceFlags -ne 'None') { if ($PropagationFlags -eq 'None') { [System.Security.AccessControl.PropagationFlags]$PropagationFlags = 'NoPropagateInherit' } else { [System.Security.AccessControl.PropagationFlags]$PropagationFlags = 'NoPropagateInherit', 'InheritOnly' } }

This does solve the problem for me.

TorstenSchnitter avatar Sep 15 '22 07:09 TorstenSchnitter