title: List of permissions for a folder and it's subfolder
body: <p>I am using PowerShell on Windows 7. I have the following code snippet and wanted to know</p>
  
  <p>Why am I not getting the SID to translate to a friendly username (on the domain)?</p>
  
  <pre><code>$OutFile = "I:\Permissions.csv"
  $RootPath = "K:\FolderName"
  
  $Folders = dir $RootPath -recurse | where {$_.psiscontainer -eq $true}
  
  foreach ($Folder in $Folders)
  {
      $ACLs = get-acl $Folder.fullname | ForEach-Object { $_.Access  }
      Foreach ($ACL in $ACLs)
      {
  
          $objSID = New-Object System.Security.Principal.SecurityIdentifier($ACL.IdentityReference.Value) 
          #$objUser = $objSID.Translate([System.Security.Principal.NTAccount]) 
          $objUser = $objSID.Translate([System.Security.Principal.SecurityIdentifier])
          $objUser.Value
  
  
          #Show User
          Write-Host “`r`nThe user mapped to SID $($objSID) is $($objUser.value)`r`n” -f “Red”
  
          $OutInfo = $Folder.Fullname + "," + $objUser.Value  + "," + $ACL.AccessControlType + "," + $ACL.IsInherited + "," + $ACL.InheritanceFlags + "," + $ACL.PropagationFlags
          Add-Content -Value $OutInfo -Path $OutFile
      }
  }
  </code></pre>
  
  <p>Desired Output would be the SAM account name. (not the Display Name)</p>
  
  <pre><code>John.Smith1
  John.Smith
  </code></pre>