Wednesday, May 30, 2018

Export File server Permissions to CSV

Export share folder Permissions to CSV file using powershell:


 $FolderPath = dir -Directory -Path "\\sharefolderPath" -Recurse -Force
 $Report = @()
 Foreach ($Folder in $FolderPath) {
     $Acl = Get-Acl -Path $Folder.FullName
     foreach ($Access in $acl.Access)
         {
             $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 "C:\tmp\FolderPermissions.csv"

No comments: