Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Remove specific user from ACL via Powershell

I want to Remove a specific user from ACL via Powershell. Not just the permission of the user for the folder.
I want the user gone from the directory.

The following post discribes my problem perfectly but the solution leads me to an 404 error^^

https://learn.microsoft.com/en-us/archive/msdn-technet-forums/6fbe497e-0ee5-41b5-802b-373466658b48

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Does anybody know the solution?

i tried with get-acl and set-acl but these are just setting and removing the permissions not deleting the user itself from the folder.

$acl = Get-Acl -Path "testfolder"

$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("testuser","ReadAndExecute","Allow")

$acl.RemoveAccessRule($AccessRule)

$acl | Set-Acl -Path "testfolder"

if my folder has lets say test1, test2, test3 users with permissions i now want to remove test1 for example. so not the permissions, i want the user gone from the folder.

>Solution :

Change this method call:

$acl.RemoveAccessRule($AccessRule)

… to:

$acl.RemoveAccessRuleAll($AccessRule)

This will remove any rule containing the given user as the identity reference, even if the rest of the ACE details don’t match.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading