Create a giant CSV of all of the ACLs for subfolders of a given path
- ToddimusPrime
- May 10, 2021
- 1 min read
Sometimes I get asked to provide a list of permissions on a ridiculous amount of folders. There's no way I'm about to pull all of that info manually...
Change the $path and $exportPath variables to suit your needs, then have at it with this script to get a CSV of some ACLs.
$path = <The location of where to start the ACL hunt goes here>
$exportPath = <The path of where to save the CSV goes here>
$FolderPath = Get-ChildItem -Directory -Path $path -Recurse -Depth 0 -Force
$Output = @()
ForEach ($Folder in $FolderPath)
{
$Acl = Get-Acl -Path $Folder.FullName
ForEach ($Access in $Acl.Access)
{
$Properties = [ordered]@{'Folder Name'=$Folder.FullName;'Group/User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
$Output += New-Object -TypeName PSObject -Property $Properties
}
}
$Output | Export-Csv $exportPath -NoTypeInformationFeel free to play around with that -Depth attribute on the third line. Be warned though, that the CSV can reach ridiculous proportions if you bring that up by too much depending on how many folders deep your file structure goes.




Comments