raandree / NTFSSecurity

Managing permissions with PowerShell is only a bit easier than in VBS or the command line as there are no cmdlets for most day-to-day tasks like getting a permission report or adding permission to an item. PowerShell only offers Get-Acl and Set-Acl but everything in between getting and setting the ACL is missing. This module closes the gap.
MIT License
431 stars 61 forks source link

Get-NTFSAccess does not actually contain Initial output #49

Open TheFitITGuy opened 5 years ago

TheFitITGuy commented 5 years ago

When trying to access the array of information from the output. It shows that the "Access Rights", "Applies to" are not actually available but only for view. Upon further investigation I found that the "Access Rights" is actually "AccessRights" but Applies to is not actually within the output. Which makes trying to use the information to correct ntfs problems an issue.

image

mwtrigg commented 5 years ago

"Applies to" is just a simpler representation of "InheritanceFlags" and "PropagationFlags", so while you can't directly filter on the "Applies to" computed value, you can filter on the appropriate combination of the flags. A breakdown of how these flags work together to create the several options can be found here:

https://stackoverflow.com/questions/3282656/setting-inheritance-and-propagation-flags-with-set-acl-and-powershell#8390274

Admittedly, it would be nice if the simplified/computed value was available to filter, but that sounds more like a feature request than a bug or issue.

TheFitITGuy commented 5 years ago

Agreed. Its a nice to have but it is available in Set-NTFSAccess . I just thought I would point it out

raandree commented 5 years ago

Thanks @mwtrigg for your input which is all correct.

There is a method that helps doing the conversion. This code can also be used in a Where-Object filter.

$pf = [System.Security.AccessControl.PropagationFlags]::None
$if = [System.Security.AccessControl.InheritanceFlags]::None

[Security2.FileSystemSecurity2]::ConvertToFileSystemFlags([Security2.ApplyTo]::SubfoldersAndFilesOnlyOneLevel, [ref]$if, [ref]$pf)

$if
$pf