powershellntfs

Powershell Folder Inheritence problem


I am having problems with a powershell script i basically trying to reset the permission on a folder, by removing the following groups

If i manually change the folder to not inherit from it parent the script works, I have look through google to find best way of removing the inheritance via a script the script compiles but not do anything.

This is the command i am using

$WebsiteACL =Get-Acl -Path "C:\websites"
$WebsiteACL.SetAccessRuleProtection($true,$false)

Does anyone have any sugestion?


Solution

  • Personally I find Get-Acl and Set-Acl still too much of a PITA to use (and I'm a C# dev). You can use icacls.exe to accomplish your task easily:

    icacls C:\temp\foo /inheritance:d
    

    It also supports removing groups. Check out its usage: icacls /?.