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

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

 

Can yo try AddAccessRule() method.