diff --git a/CHANGELOG.md b/CHANGELOG.md
index 16e8e40..76c05c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -88,5 +88,7 @@ The format is based on
- Fix the inheritance cmdlets, which enabled the Backup, Restore, Take
Ownership, and Security privileges even when the module setting
`EnablePrivileges` was `$false`, and left them enabled
+- Fix the `Inherits` column of the `Get-ChildItem2` output, which showed
+ `True` for every item, also for items whose inheritance is disabled
[Unreleased]: https://github.com/raandree/NTFSSecurity/compare/4.2.6...HEAD
diff --git a/Docs/Cmdlets/Get-ChildItem2.md b/Docs/Cmdlets/Get-ChildItem2.md
index 5ae3191..0bd8f8a 100644
--- a/Docs/Cmdlets/Get-ChildItem2.md
+++ b/Docs/Cmdlets/Get-ChildItem2.md
@@ -301,6 +301,8 @@ The cmdlet returns this object for every folder it finds. Depending on the modul
The module defines the alias `dir2` for this cmdlet.
+The default table view shows the `Mode`, `Inherits`, `LastWriteTime`, `Size(M)`, and `Name` columns. `Inherits` is `False` for an item whose access inheritance is disabled. Before 5.0.0, the column showed `True` for every item.
+
The `PrivateData` section of the module manifest `NTFSSecurity.psd1` contains two settings that this cmdlet reads when it starts. `GetFileSystemModeProperty` adds the calculated `Mode` property to every item. `IdentifyHardLinks` adds the `HardLinkCount` property to every file, which requires an extra call into the file system for each file and therefore slows down large listings noticeably. Set either value to `$false` in the manifest and import the module again if you prefer the faster enumeration over the additional properties.
A folder that cannot be read produces a non-terminating error with the ID `DirUnauthorizedAccessError` for an access denial or `DirUnspecifiedError` for any other failure, and a path that does not exist produces the error `FileNotFound`. In each case the cmdlet continues with the next path. Failures that occur while `-Recurse` collects the subfolders of a folder are reported as verbose messages only, not as errors.
diff --git a/NTFSSecurity/NTFSSecurity.format.ps1xml b/NTFSSecurity/NTFSSecurity.format.ps1xml
index d931bff..455df7c 100644
--- a/NTFSSecurity/NTFSSecurity.format.ps1xml
+++ b/NTFSSecurity/NTFSSecurity.format.ps1xml
@@ -430,7 +430,7 @@
- !$_.IsInheritanceBlocked
+ -not $_.GetAccessControl([System.Security.AccessControl.AccessControlSections]::Access).AreAccessRulesProtected
diff --git a/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml b/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml
index 0ba7b55..166bd71 100644
--- a/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml
+++ b/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml
@@ -3841,6 +3841,7 @@ PS C:\> Disable-Privileges
`Get-ChildItem2` enumerates the file system through the AlphaFS library (`Alphaleonis.Win32.Filesystem`), which is why it returns items whose path exceeds the 260-character `MAX_PATH` limit that the built-in `Get-ChildItem` cmdlet is bound to. The objects are AlphaFS objects, not `System.IO` objects, and the other NTFSSecurity cmdlets accept them directly because their `-Path` parameters have the alias `FullName`.
The module defines the alias `dir2` for this cmdlet.
+ The default table view shows the `Mode`, `Inherits`, `LastWriteTime`, `Size(M)`, and `Name` columns. `Inherits` is `False` for an item whose access inheritance is disabled. Before 5.0.0, the column showed `True` for every item.
The `PrivateData` section of the module manifest `NTFSSecurity.psd1` contains two settings that this cmdlet reads when it starts. `GetFileSystemModeProperty` adds the calculated `Mode` property to every item. `IdentifyHardLinks` adds the `HardLinkCount` property to every file, which requires an extra call into the file system for each file and therefore slows down large listings noticeably. Set either value to `$false` in the manifest and import the module again if you prefer the faster enumeration over the additional properties.
A folder that cannot be read produces a non-terminating error with the ID `DirUnauthorizedAccessError` for an access denial or `DirUnspecifiedError` for any other failure, and a path that does not exist produces the error `FileNotFound`. In each case the cmdlet continues with the next path. Failures that occur while `-Recurse` collects the subfolders of a folder are reported as verbose messages only, not as errors.
Before 5.0.0, a `-Path` value that points to a file stopped the cmdlet with an `InvalidCastException`.
diff --git a/Tests/ItemCmdlets.Tests.ps1 b/Tests/ItemCmdlets.Tests.ps1
index 5534a0e..3a7ca2c 100644
--- a/Tests/ItemCmdlets.Tests.ps1
+++ b/Tests/ItemCmdlets.Tests.ps1
@@ -54,6 +54,30 @@ Describe 'Get-ChildItem2' {
$items | Should -BeNullOrEmpty
}
}
+
+ Context 'Default table view' {
+ BeforeAll {
+ $viewFolder = New-TestSandboxItem -Sandbox $sandbox -Name 'View' -Directory
+ $blocked = Join-Path -Path $viewFolder -ChildPath 'Blocked.txt'
+ $inheriting = Join-Path -Path $viewFolder -ChildPath 'Inheriting.txt'
+ Assert-TestSandboxPath -Sandbox $sandbox -Path $blocked, $inheriting
+ Set-Content -LiteralPath $blocked -Value 'Blocked'
+ Set-Content -LiteralPath $inheriting -Value 'Inheriting'
+ $acl = Get-Acl -LiteralPath $blocked
+ $acl.SetAccessRuleProtection($true, $true)
+ Set-Acl -LiteralPath $blocked -AclObject $acl
+
+ $lines = Get-ChildItem2 -Path $viewFolder | Out-String -Stream -Width 200
+ }
+
+ It 'Should show False in the Inherits column for a file whose inheritance is disabled' {
+ ($lines | Where-Object -FilterScript { $_ -match 'Blocked\.txt\s*$' }) | Should -Match '\bFalse\b'
+ }
+
+ It 'Should show True in the Inherits column for a file that inherits' {
+ ($lines | Where-Object -FilterScript { $_ -match 'Inheriting\.txt\s*$' }) | Should -Match '\bTrue\b'
+ }
+ }
}
Describe 'Copy-Item2' {