# Specify the root folder path
$rootFolderPath = "C:\Temp"
# Get all items (files and subfolders) under the root folder
$items = Get-ChildItem -Path $rootFolderPath -Recurse
# Iterate through each item
foreach ($item in $items) {
# Get the ACL for the item
$acl = Get-Acl -Path $item.FullName
# Check if any explicit permissions exist (not inherited)
$explicitPermissions = $acl.Access | Where-Object { $_.IsInherited -eq $false }
if ($explicitPermissions.Count -gt 0) {
Write-Host "Explicit permissions found for $($item.FullName):"
foreach ($permission in $explicitPermissions) {
Write-Host " User: $($permission.IdentityReference)"
Write-Host " Permissions: $($permission.FileSystemRights)"
Write-Host " Access Control Type: $($permission.AccessControlType)"
Write-Host " Inherited: $($permission.IsInherited)"
Write-Host ""
}
}
}