Assign user ACL permissions to a folder and sub directory using powershell

Welcome Forums General PowerShell Q&A Assign user ACL permissions to a folder and sub directory using powershell

Viewing 1 reply thread
  • Author
    Posts
    • #179943
      Participant
      Topics: 1
      Replies: 0
      Points: 11
      Rank: Member

      Hello,

      Using a powershell script, I would like to add read and execute permission to a folder and its sub directories.

      I user the following code:

      $path = "\\domain.com\users\users1\test54"
      $user = "test54@domain.com"
      $Rights = "Read, ReadAndExecute, ListDirectory"
      $InheritSettings = "Containerinherit, ObjectInherit"
      $PropogationSettings = "None"
      
      $RuleType = "Allow"
      
      $acl = Get-Acl $path
      $perm = $user, $Rights, $InheritSettings, $PropogationSettings, $RuleType
      $rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $perm
      $acl.SetAccessRule($rule)
      $acl | Set-Acl -Path $path
      

      However, when I execute this code (my account has admin level access), the ACL for this folder does not include the account test54.

      What needs to be done so that I can add the user with access rights Read /List/Execute to the ACL  of the specified folder?

      Thanks in advance!

      Mark

       

    • #179952
      Senior Moderator
      Topics: 8
      Replies: 1155
      Points: 4,019
      Helping Hand
      Rank: Community Hero

      Can yo try AddAccessRule() method.

Viewing 1 reply thread
  • The topic ‘Assign user ACL permissions to a folder and sub directory using powershell’ is closed to new replies.