ntfs - Powershell Get-NTFSAccess Applies to - Stack Overflow

admin2025-04-27  3

The command Get-NTFSAccess output displays column "Applies to", how can I read this value to a variable?

The command output is added to a variable, but I cannot read the Applies to column, when I try $variable."Applies to" nothing is returned. I tried with single quotes and curly braces, but no values are returned.

$Object = "C:\temp\testfolder"
$acl    = Get-NTFSAccess -Path $Object

# Loop through each access rule in the ACL
foreach ($record in $acl) {
    # Create a custom object to store the details
    $result = [PSCustomObject]@{
        FilePath      = $Object
        Principal     = $record.Account
        Type          = $record.AccessControlType
        Access        = $record.AccessRights
        Inherited     = $record.IsInherited
        InheritedFrom = $record.InheritedFrom
        Scope         = $record."Applies to"
    }

    # Add the result to the array
    $results += $result
}
转载请注明原文地址:http://anycun.com/QandA/1745707159a91101.html