title: PowerShell folder permission error - Some or all identity references could not be translated
body: <p>I am running this script as Admin and It does create the folders requred, just does not set the appropriate permissions.</p>
  <pre><code>$Users = Get-Content &quot;D:\New_Users.txt&quot;
  ForEach ($user in $users)
  {
      $newPath = Join-Path &quot;F:\Users&quot; -childpath $user
      New-Item $newPath -type directory
          
      $UserObj = New-Object System.Security.Principal.NTAccount(&quot;DOMAIN&quot;,$user)
    
      $acl = Get-Acl $newpath
      $acl.SetAccessRuleProtection($True, $False)
      $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule(&quot;O1OAK\$user&quot;,&quot;AppendData,CreateDirectories,CreateFiles,DeleteSubdirectoriesAndFiles,ExecuteFile,ListDirectory,Modify,Read,ReadAndExecute,ReadAttributes,ReadData,ReadExtendedAttributes,ReadPermissions,Synchronize,Traverse,Write,WriteAttributes,WriteData,WriteExtendedAttributes&quot;,&quot;ContainerInherit, ObjectInherit&quot;,&quot;None&quot;,&quot;Allow&quot;)
      $acl.SetAccessRule($accessRule)
      $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule(&quot;NT AUTHORITY\SYSTEM&quot;,&quot;FullControl&quot;,&quot;ContainerInherit, ObjectInherit&quot;,&quot;None&quot;,&quot;Allow&quot;)
      $acl.SetAccessRule($accessRule)
      $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule(&quot;BUILTIN\Administrators&quot;,&quot;FullControl&quot;,&quot;ContainerInherit, ObjectInherit&quot;,&quot;None&quot;,&quot;Allow&quot;)
      $acl.SetAccessRule($accessRule)
      $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule(&quot;1OAK\$user&quot;,&quot;Delete&quot;,&quot;ContainerInherit, ObjectInherit&quot;,&quot;None&quot;,&quot;Allow&quot;)
      $acl.removeAccessRule($accessRule)
      $acl.SetOwner($UserObj)
      $acl | Set-Acl $newpath
  }
  </code></pre>
  <p>The first error in a string of 3 that I get is below. I think it is the most important and will fix the other 2.</p>
  <pre><code>Exception calling &quot;SetAccessRule&quot; with &quot;1&quot; argument(s): &quot;Some or all identity references could not be translated.&quot;
  At D:\DOMAIN\IT\IT Private\User Drives\user_folders.ps1:12 char:20
  +     $acl.SetAccessRule &lt;&lt;&lt;&lt; ($accessRule)
      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : DotNetMethodException
  </code></pre>