Hi,
I’m trying to set permissions on a folder then make all child folders/files inherit those permissions of the parent folder.
Here is what I have so far. It will set the permissions to the parent but child folders/files are not getting the inherited permissions.
$path = 'C:\temp\test'
Get the ACL for an existing folder
$existingAcl = (Get-Item $path).GetAccessControl('Access')
$allInherit = [System.Security.AccessControl.InheritanceFlags]"ContainerInherit","ObjectInherit"
Set the permissions that you want to apply to the folder
$permissions = $env:username,"FullControl",$allInherit,"None","Allow"
Create a new FileSystemAccessRule object
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule $permissions
Modify the existing ACL to include the new rule
$existingAcl.SetAccessRule($rule)
#Enable Inheritance
$existingAcl.SetAccessRuleProtection($false,$true)
Apply the modified access rule to the folder
Set-Acl -path $path -AclObject $existingAcl
Any help is appreciated, thanks!