Trying to set ACL via PowerShell to UNC path

Posted on 2011-05-02
Last Modified: 2012-05-11
I'm trying to set ACL via powershell. My script is here:

$acl = Get-Acl $folder
$permission = "domain\$user","FullControl","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl | Set-Acl $folder

This $folder variable content is UNC path.

When I run this script I get error message:
Exception calling "SetAccessRule" with "1" argument(s): "Some or all identity references could not be translated."
At C:\temp\FTPUser.ps1:50 char:19
+ $acl.SetAccessRule <<<< ($accessRule)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

What I have done incorrectly?

Question by:thaapavuori
    LVL 16

    Expert Comment

    by:Bryan Butler
    Maybe try specifying explicitly:

    $permission = $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule ("users","FullControl","Allow")

    Also, in your script, where is $user set?
    LVL 16

    Accepted Solution

    I meant:

    $accessRule =
    New-Object System.Security.AccessControl.FileSystemAccessRule("users","FullControl","Allow")


    Author Comment

    Thanks this was woking. I was still able to use $user variable. This $user has been typed before by end user.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    Title # Comments Views Activity
    Powershell to find a users workstation 11 72
    compare email address 4 28
    Powershell Question 9 38
    Powershell: Compatre 2 files 4 23
    Set OWA language and time zone in Exchange for individuals, all users or per database.
    Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    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

    13 Experts available now in Live!

    Get 1:1 Help Now