Forum Discussion

suren424's avatar
suren424
Copper Contributor
Oct 11, 2020
Solved

Getting a parent's parent for a folder using power shell

Hi,   I am using a powershell script to enable inheritance for the folders created in NTFS share.  In this script, i am getting the folder created for the user by passing a dynamic value and then ...
  • farismalaeb's avatar
    farismalaeb
    Oct 17, 2020

    suren424 

    the script seems to be working,

    I try it on my side and the result was correct, good job.

    $Permission.SetAccessRuleProtection($False,$true)
    Set-Acl -Path $allFolders.FullName -AclObject $Permission

    In the first line and as the $Permission is holding the folder ACL information, there is one of the methods called SetAccessRuleProtection, you can find all other methods and properties by using $Permission | Get-Member.

    More info here

    The SetAccessRuleProtection accepts 2 input IsProtected and PreservedInheritance 

    SetAccessRuleProtection (bool isProtected, bool preserveInheritance);

    IsProtected: Type is Bool ($True/$false) , $False= Enable Inheritance

    PreservedInheritance : This parameter is actually ignored as the IsProtected is set to false

     

    Thanks

     

    -------------------------

    Feel free to respond and request more information, if you find the answer that satisfy your need, Please make sure to mark it as Best Response and like the other.