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!
The RemoveAccessRule method removes either all matching Deny access rules or all matching Allow access rules from the current FileSystemSecurity object.
Hover over the desired shared folder and click Sharing. Locate the user and click on the Permissions button. Select the appropriate permission settings for the user. To remove access, click Remove member.
To remove an ACL entry, create a new ACL object for ACL entry to be removed, and then use that object in remove ACL operation. Do not get the existing ACL, just provide the ACL entries to be removed. Remove ACL entries by using the Remove-AzDataLakeGen2AclRecursive cmdlet.
$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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With