Set folder inheritance

 

folder

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. http://richardspowershellblog.wordpress.com/2008/02/06/file-system-allow-inheritable-permissions-from-parent-to-propagate/

#----------------
---------------------------------------------
#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 
$acl.AreAccessRulesProtected
$isProtected = $false
$preserveInheritance = $true
$acl.SetAccessRuleProtection($isProtected, $preserveInheritance)
Set-Acl -Path $path -AclObject $acl 
}