diff --git a/Docs/Cmdlets/Clear-NTFSAccess.md b/Docs/Cmdlets/Clear-NTFSAccess.md index 7c2278b..62ff672 100644 --- a/Docs/Cmdlets/Clear-NTFSAccess.md +++ b/Docs/Cmdlets/Clear-NTFSAccess.md @@ -72,7 +72,7 @@ These commands replace the complete ACL of `C:\Data` in one write. The security ### -DisableInheritance -Indicates that inheritance is disabled after the explicit entries are removed, and that the inherited entries are discarded rather than copied into the item. Without this switch the inherited entries remain in effect. +Indicates that inheritance is disabled after the explicit entries are removed, and that the inherited entries are discarded rather than copied into the item. The item is left with an empty DACL, which denies access to everyone; only its owner can still change the permissions. Without this switch the inherited entries remain in effect. ```yaml Type: SwitchParameter diff --git a/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml b/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml index cea22cd..781722d 100644 --- a/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml +++ b/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml @@ -1601,7 +1601,7 @@ PS C:\> Set-NTFSSecurityDescriptor -SecurityDescriptor $sd DisableInheritance - Indicates that inheritance is disabled after the explicit entries are removed, and that the inherited entries are discarded rather than copied into the item. Without this switch the inherited entries remain in effect. + Indicates that inheritance is disabled after the explicit entries are removed, and that the inherited entries are discarded rather than copied into the item. The item is left with an empty DACL, which denies access to everyone; only its owner can still change the permissions. Without this switch the inherited entries remain in effect. SwitchParameter @@ -1628,7 +1628,7 @@ PS C:\> Set-NTFSSecurityDescriptor -SecurityDescriptor $sd DisableInheritance - Indicates that inheritance is disabled after the explicit entries are removed, and that the inherited entries are discarded rather than copied into the item. Without this switch the inherited entries remain in effect. + Indicates that inheritance is disabled after the explicit entries are removed, and that the inherited entries are discarded rather than copied into the item. The item is left with an empty DACL, which denies access to everyone; only its owner can still change the permissions. Without this switch the inherited entries remain in effect. SwitchParameter @@ -1642,7 +1642,7 @@ PS C:\> Set-NTFSSecurityDescriptor -SecurityDescriptor $sd DisableInheritance - Indicates that inheritance is disabled after the explicit entries are removed, and that the inherited entries are discarded rather than copied into the item. Without this switch the inherited entries remain in effect. + Indicates that inheritance is disabled after the explicit entries are removed, and that the inherited entries are discarded rather than copied into the item. The item is left with an empty DACL, which denies access to everyone; only its owner can still change the permissions. Without this switch the inherited entries remain in effect. SwitchParameter diff --git a/Tests/Access.Tests.ps1 b/Tests/Access.Tests.ps1 index 49a67bc..b423e0f 100644 --- a/Tests/Access.Tests.ps1 +++ b/Tests/Access.Tests.ps1 @@ -285,3 +285,20 @@ Describe 'Security descriptor parameter sets' { $rule.InheritanceFlags | Should -Be ([System.Security.AccessControl.InheritanceFlags]::None) } } + +Describe 'Clear-NTFSAccess' { + Context 'With -DisableInheritance' { + # The cmdlet does not copy the inherited entries, so the item is left with an empty DACL. This is the + # documented behavior; Set-NTFSInheritance and Disable-NTFSAccessInheritance keep the entries. + It 'Should leave the item with an empty, protected DACL' { + $file = New-TestSandboxItem -Sandbox $sandbox -Name 'ClearAll' + Assert-TestSandboxPath -Sandbox $sandbox -Path $file + + Clear-NTFSAccess -Path $file -DisableInheritance + + $acl = Get-Acl -LiteralPath $file + $acl.AreAccessRulesProtected | Should -BeTrue + $acl.Access | Should -BeNullOrEmpty + } + } +} \ No newline at end of file