powershell: set-acl to UNC path removes existing permissions

Posted on 2011-10-03
Last Modified: 2012-05-12

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

Question by:staino1983
    LVL 18

    Expert Comment

    this will add the new FileSystemAccessRule to the colection retrieved from the folder:

    $ACL = $ACL.Access + $accessRule
    LVL 67

    Expert Comment

    All examples I've seen talk about using $acl.SetAccessRule, not .AddAccessRule, to add ACLs. Try that.

    Accepted Solution

    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.


    Author Closing Comment

    resolved myself

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
    I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now