powershell: set-acl to UNC path removes existing permissions


When I try and set "ReadPermissions" for a security group to a UNC path - eg \\computer\test, the group is added with the required permissions. However the existing permissions are all removed.

If I run the script against the local drive, eg c:\test, the permissions are not deleted.

How do I keep the existing permissions when applying the script to a UNC path?

Please note that I have to use UNC path and can not do local drive or use C$


$folder = "\\computer\test"
$ADgroup = "AD_GROUP"

$ACL = get-acl $folder
$accessLevel = "ReadPermissions"
$inheritanceFlags = "None"
$propagationFlags = "none"
$accessControlType = "Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($ADgroup,$accessLevel,$inheritanceFlags,$propagationFlags,$accessControlType)
Set-Acl $folder $Acl

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

x-menIT super heroCommented:
this will add the new FileSystemAccessRule to the colection retrieved from the folder:

$ACL = $ACL.Access + $accessRule
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
All examples I've seen talk about using $acl.SetAccessRule, not .AddAccessRule, to add ACLs. Try that.
staino1983Author Commented:
Thanks for the help

The problem was that I was testing the UNC path against my own computer which had UAC enabled. For whatever reason, UAC was causing this issue. If I turned UAC off, the script would work. If I run against a remote server with the UNC path, it also works fine.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
staino1983Author Commented:
resolved myself
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.