Export Folder Permission to csv

Export Folder Permission to csv

2021/06/23 Office 365 Programming 0
#$FolderPath = dir -Directory -Path "\\fs1\Shared" -Recurse -Force
$FolderPath = dir -Directory -Path "." -Recurse -Force
$Report = @()
Foreach ($Folder in $FolderPath) {
    $Acl = Get-Acl -Path $Folder.FullName
    foreach ($Access in $acl.Access)
        {
		$Folder.FullName
		$Properties = [ordered]@{'FolderName'=$Folder.FullName;
		'AD Group or
		User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
		$Report += New-Object -TypeName PSObject -Property $Properties
        }
}
$Report | Export-Csv -path "FolderPermissions.csv"

Leave a Reply

Your email address will not be published.