Hi there

Have you ever to export file and folder security ACLs from a specific folder on disk or remote network path on a server?

The following approach it’s kind old school but works.

cd c:\temp
cacls . to list current dir only
cacls *.* to list all folder and subfolders from the current folder (root folder)

However, you can have a better and filtered result using the following PowerShell file.

###############################################################################################################################################################################################################################################
# Author Thiago Beier thiago.beier@gmail.com 
# Version: 1.0 - 2020-03-10
# Export disk permissions (folder permissions to CSV)
# Toronto, CANADA 
# Email: thiago.beier@gmail.com 
# https://www.linkedin.com/in/tbeier/ 
# https://twitter.com/thiagobeier
# thiagobeier.wordpress.com
###############################################################################################################################################################################################################################################

#folter to scan - retrieve security information from
$FolderPath = Get-ChildItem -Directory -Path 'C:\temp' -Recurse -Force -ErrorAction SilentlyContinue

#get date time and adds to the log file
$gt=Get-Date -Format "dddd-mm-dd-yyyy-HH-mm-ss"

$Report = @()
Foreach ($Folder in $FolderPath) {
$Acl = Get-Acl -Path $Folder.FullName
foreach ($Access in $acl.Access)
{
$Properties = [ordered]@{'FolderName'=$Folder.FullName;'ADGroup or User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
$Report += New-Object -TypeName PSObject -Property $Properties
}
}
#expor tto CSV with date and time on CSV file
$Report | Export-Csv -path "c:\temp\FolderPermissions-$gt.csv"

Feel free to change c:\temp under $FolderPath variable and filename at line #28 for the CSV file path

c:\temp folder content with all files exported (different exports)

CSV file content output

Tip! – you can download this script from GitHub repository.

thanks,

Thiago Beier
TwitterLinkedInFacebookRSS