Set folder inheritance



In the last blogg I wrote in how to find differens in source and target folder inheritance. Here is a scritpt to enable the inheritance on multiple folders listed in an csv-file. The acl.SetAccessruleProtection line only sets the flag and the you have to commit with set-acl, hopefully this will change in future versions.

Had to use google on this one because the strange way to implement this.

#NAME: Set folder inheritance.ps1
#AUTHOR: Viktor Lindström
#COMMENTS: Set inheritance behavior on folders 
$Import = import-csv "c:\test\folders.csv

foreach ($path in $import)
$acl= Get-Acl -Path $path 
$isProtected = $false
$preserveInheritance = $true
$acl.SetAccessRuleProtection($isProtected, $preserveInheritance)
Set-Acl -Path $path -AclObject $acl