Set-ACL and Special Permissions

Set-ACL and Special Permissions

Post by TWFyY3VzIE » Sat, 01 Nov 2008 11:19:19



Hi There,

I was trying to use Powershell to automate a task to set special permissions
to folders.
It consist of special permissions that applies to the root folder, and a
different set of permission to subfolders and files for the SAME user.
I can do it manually but when I try to use set-acl, it doesn't seem to allow
2 access rules for the same user.
No error is reported only the last access rule overwrites whatever setting
was there for that specific user.

Any help will be highly appreciated.

Thanks,

Marcus

Here is my code:



$str = "CONTOSO\TEST1","Modify, Synchronize","none","none","Allow"
$str1 = "CONTOSO\TEST1","FullControl","ContainerInherit,
ObjectInherit","InheritOnly","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule
$str
$accessRule1 = New-Object System.Security.AccessControl.FileSystemAccessRule
$str1
$ACL = get-acl c:\TEST
$ACL.SetAccessRule($accessRule)
$ACL.SetAccessRule($accessRule1)
Set-Acl c:\TEST $ACL # Set the Permission
 
 
 

Set-ACL and Special Permissions

Post by Vadims Pod » Sat, 01 Nov 2008 17:47:08

You should use AddAccessRule instead SetAccessRule (which replaces all ACE
for user):

$ACL.AddAccessRule($accessRule)
$ACL.AddAccessRule($accessRule1)

for additional information see:
http://www.yqcomputer.com/

 
 
 

Set-ACL and Special Permissions

Post by TWFyY3VzIE » Sat, 01 Nov 2008 23:28:03

Awesome!

Thanks,
Marcus