PowerShell – How to Report on NTFS File/Folder 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 –

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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