Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set-ACL and Special Permissions

227 views
Skip to first unread message

Marcus Juca

unread,
Oct 30, 2008, 10:19:19 PM10/30/08
to

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

Vadims Podans

unread,
Oct 31, 2008, 4:47:08 AM10/31/08
to
You should use AddAccessRule instead SetAccessRule (which replaces all ACE
for user):

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

for additional information see:
http://msdn.microsoft.com/en-us/library/d49cww7f.aspx


"Marcus Juca" <Marcu...@discussions.microsoft.com> wrote in message
news:35DADB13-5AFB-453C...@microsoft.com...

Marcus Juca

unread,
Oct 31, 2008, 10:28:03 AM10/31/08
to
Awesome!

Thanks,
Marcus

0 new messages