Remove NTFS rights inheritance using Powershell

So I needed to remove the inheritance of a folder. Yes its easy to do with icacls, just icacls /inheritance:e|d|r. Where E is enable, D is copy all ACEs and R removes all inherited rights.
But this is about doing it with powershell.

Thats all.. But what happened.. lets break it up.

  1. Assigned a folder path to a variable called $folder
  2. Read the rights of the folder and saved in the variable $acl
  3. Remove the inheritance but copy the ACEs
  4. Set the ACL to the folder so its done.

So that is the $True,  $True part. Well The first part says is this folder protected or not (opposite of inherited). The second is should the current ace be copied. So if you set the first to $False inheritance will be restored.

Trackbacks

  1. […] a script to remove permissions inheritance from multiple folders. So a quick google found this link, which I used to create the simple script […]

  2. […] a script to remove permissions inheritance from multiple folders. So a quick google found this link, which I used to create the simple script […]

Leave a Reply