I have a script that sets permissions on my newly created folders. One thing I am finding is that it is turning off inheritable permissions. I have tried to set this, but nothing seems to work. This is what I am referring to:

As you can see, it is not enabled after running my script. So, I tried writing a new script to change it. No dice. here is my code:

foreach($_ in (Get-ChildItem "C:\SHARES\folder\docs" -recurse)){
if($_.name -eq "docs"){
$inheritance = Get-Acl -path $_.fullname
$inheritance.SetAccessRuleProtection($true,$true)
set-acl -path $_.fullname -aclobject $inheritance
}}

Any suggestions to fix this?

4 Spice ups

May nee to be this:

$inheritance.SetAccessRuleProtection($false, $true)

More discussion of the settings on stackoverflow: inheritance - Explain for beginners the ACL object property "SetAccessRuleProtection" in PowerShell with examples - Stack Overflow

2 Spice ups

I’m an idiot. I had my folder path set wrong this whole time!

I would simply use 1 liner

icacls C:\scripts /inheritance:E
1 Spice up