Announcement

Collapse
No announcement yet.

Set-ACL Error

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Set-ACL Error

    Hello all,

    I am trying to set special permissions on a folder however if i use more than 3 arguments i get an error: Cannot find an overload for "FileSystemAccessRule"and the argument count .....

    It looks like if i use more than 3 arguments it shows this behaviour.

    My code looks like:

    Code:
    $Profiles = "PATH TO FOLDER"
    $acl_Profiles = Get-Acl $Profiles
    
    $acl_Profiles.SetAccessRuleProtection($true,$false)
    
    $Users = "BUILTIN\Users","CreateFiles", "AppendData", "ReadExtendedAttributes", "ExecuteFile", "ReadAttributes", "ReadPermiss", "Allow"
    
    $accessRule6 = New-Object System.Security.AccessControl.FileSystemAccessRule $Users
    $acl_Profiles.SetAccessRule($accessRule6)
    
    $acl_Profiles | Set-Acl $Profiles
    Is someone familiar with this?

  • #2
    Re: Set-ACL Error

    PowerShell takes any comma separated list and turns it into an array. So $users is an array of strings which is not what is expected when you create the access rule. You need to do something like this:

    [System.Security.Principal.NTAccount]$account="Builtin\Users"
    $rights = "CreateFiles", "AppendData", "ReadExtendedAttributes", "ExecuteFile", "ReadAttributes", "ReadPermissions"
    $accessRule6 = New-Object System.Security.AccessControl.FileSystemAccessRule ($account,$rights,"Allow")

    Comment


    • #3
      Re: Set-ACL Error

      Jeff thanks, it works now!!!

      Comment

      Working...
      X