title: Powershell - How to Give Full Access a List of Local User for Folders
body: <p>I have a CSV file that containts a Folder Name (first 6 characters) and a User Name (rest of characters).
  I have to give Full Control Access to each User in His Folder. So I wrote the:</p>
  
  <pre><code>$Doc = import-csv "C:\Temp\ListOfUsers.csv"
  
  foreach ($x in $Doc)
    {
  
       $x = ""+ $x
  
       $CPayID = $x.SubString(10,6)
  
       $UserName = $x.SubString(17, $x.Length-18)
  
       $UserPath = "C:\XPAY_FTP_CUST\"+$CPayID
  
       $Acl = Get-Acl $UserPath
  
       $Rule = New-Object System.Security.AccessControl.FileSystemAccessRule("$Username","FullControl","ContainerInherit, ObjectInherit","None","Allow")
  
       $Acl.SetAccessRule($Rule)
  
       Set-Acl $UserPath $Acl
    }
  </code></pre>
  
  <p>But I received the following Error for Each User:</p>
  
  <blockquote>
    <p>Exception calling "SetAccessRule" with "1" argument(s): "Some or all identity references could not be translated."</p>
  </blockquote>
  
  <p>The Users exist and are locals, I am local administrator, and when I ask for echo the <code>$Username</code>, the <code>$UserPath</code>, and the <code>$Acl</code> I receive correct data.
  Please, I need any help.</p>