Remove any user from NTFS permission

Rafael S. Amaral 1 Reputation point
2022-05-27T12:54:29.667+00:00

Hi guys,

I need to remove any user that is in NTFS permission.

I have the list of folders and child folders, these folders only need to have groups (The groups are already configured), is this possible by powershell?

Thanks!

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,381 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rafael S. Amaral 1 Reputation point
    2022-05-27T15:16:39.627+00:00

    Can anyone guide me how can I automate this command?

    I configured a specific folder and a specific user and I was able to remove it, but it is to remove any user that is in the folder list.


    $Acl = Get-Acl -Path "c:\temp\test"

    $Ace = $Acl.Access | Where-Object {($.IdentityReference -eq 'RSA\user1') -and -not ($.IsInherited)}

    $Acl.RemoveAccessRule($Ace)

    Set-Acl -Path "c:\temp\test" -AclObject $Acl

    0 comments No comments