I have a PowerShell script that matches Get-ACL Access Control Entries to standard Windows permissions using the access mask. Oddly, ACEs like "ReadAndExecute, Synchronize" seem to yield a permission of "FullControl". Here is the script:
#Match current ACE permissions to regular permissions via access mask comparison (binary and / -band)
$acl = Get-Acl "C:\Program Files (x86)"
$accesses = $acl.Access
#Enumerate current directory's access rights
foreach ($access in $accesses) {
$Enumeration = $access.FileSystemRights
$keys = @()
[System.Enum]::GetValues($Enumeration.GetType()) | Where-Object { $Enumeration -band $_; write-host ($Enumeration -band $_) -ForegroundColor Red} | % {write-host -ForegroundColor Green $_;} | Select-Object -Unique | ForEach-Object { write-host -ForegroundColor Cyan $_; $keys += $_ }
$keys
}
Perhaps I do not fully understand how to appropriately translate these Access Control Entries. It seems odd to me that "Modify, Synchronize" would somehow end up in the permission setting of "FullControl".
Also, if this script is run on your own system you will note the rather messy debug format it currently portrays. The "0"'s are simply non-matching results from the binary "and". The green values are the resultant Windows permissions from the ACEs that had matching access masks for the specified Windows permission (supposedly).
I hope that I am not repeating anything with this question; I've dug and haven't found an answer that explains this to me at my current level of understanding.
$Enumeration -band $_;
->($Enumeration -band $_) -eq $_;
– user4003407