Search code examples
powershellpermissionsdirectory

powershell remove all permissions on a folder for a specific user


I need a script or simple powershell code for removing all permissions to a folder for specific user, by inheriting these deletion to all the subfolders and files as well - recursively... Thank you in advance!


Solution

  •  $acl=get-acl c:\temp
     $accessrule = New-Object system.security.AccessControl.FileSystemAccessRule("domain\user","Read",,,"Allow")
     $acl.RemoveAccessRuleAll($accessrule)
     Set-Acl -Path "c:\temp" -AclObject $acl
    

    this should wipe all security rules for user in c:\temp recursively