Link to home
Start Free TrialLog in
Avatar of Stéphane Boisvert
Stéphane BoisvertFlag for Canada

asked on

powershell script to get list of user have acces to folder and sub folder

Hi,

i need to get list off users have an acces to files under folder and subfolders
i have many different access and each of my folders have different security group
i need to get all the users of all groups with the folder name

presently i use this script but i cant get the member of each groups in same time

$OutFile = "C:\temp\Permissions.csv"
$Header = "Folder Path,IdentityReference,AccessControlType,IsInherited,InheritanceFlags,PropagationFlags"
Add-Content -Value $Header -Path $OutFile

$RootPath = "\\my root folder\"

$Folders = dir $RootPath -recurse | where {$_.psiscontainer -eq $true}

foreach ($Folder in $Folders){
      $ACLs = get-acl $Folder.fullname | ForEach-Object { $_.Access  }
      Foreach ($ACL in $ACLs){
      $OutInfo = $Folder.Fullname + "," + $ACL.IdentityReference  + "," + $ACL.AccessControlType + "," + $ACL.IsInherited + "," + $ACL.InheritanceFlags + "," + $ACL.PropagationFlags
      Add-Content -Value $OutInfo -Path $OutFile
      }
}
Avatar of amodeo
amodeo

If it doesn't absolutely have to be a powershell script, netwrix makes a completely free tool that does this.  I know it doesn't directly answer your question but I have found it very helpful for this info.

https://www.netwrix.com/netwrix_effective_permissions_reporting_tool.html

-Joe
ASKER CERTIFIED SOLUTION
Avatar of Dustin Saunders
Dustin Saunders
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stéphane Boisvert

ASKER

Thank you Dustin for your comment
it work perfectly
Asker confirmed solution works for them.