Windows permissions are sometimes very complex to understand.
Below snippet can be used to get the list of all the permissions list:
# Define the directory path to inspect
$directoryPath = "C:\MyDirectory"
# Get ACLs for the directory and its subdirectories
$directoryACLs = Get-ChildItem -Path $directoryPath -Recurse |
Get-Acl |
Select-Object -ExpandProperty Access
# Output information about each ACL
foreach ($acl in $directoryACLs) {
Write-Output "Path: $($acl.Path)"
Write-Output "IdentityReference: $($acl.IdentityReference)"
Write-Output "FileSystemRights: $($acl.FileSystemRights)"
Write-Output "AccessControlType: $($acl.AccessControlType)"
Write-Output "IsInherited: $($acl.IsInherited)"
Write-Output "-----------------------------"
}
Thanks!!
No comments:
Post a Comment