PowerShell – How to Report on NTFS File Inheritance & Permissions

The script below was taken from https://www.lepide.com/how-to/get-an-ntfs-permissions-report-using-powershell.html

The script takes a directory path to search from, it will then get a list of all subdirectories, loop through each of them then generate a nice grid view report of all permissions in subdirectories and whether they are inherited.

$DirectoryToSearch = ""
$DirectoryPath = Get-ChildItem -Directory -Path $DirectoryToSearch -Recurse -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 | Out-GridView

This should generate a report similar to the image below –

One response to “PowerShell – How to Report on NTFS File Inheritance & Permissions”

  1. Kaviarasu Avatar
    Kaviarasu

    $DirectoryPath should be replaced as $FolderPath, nice script.

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Design a site like this with WordPress.com
Get started