Repository navigation
Closed
Labels
Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issuesWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Description
The inability to list a child directory's contents due to lack of permission correctly results in a (non-terminating) error when using Get-ChildItem -Recurse.
Simply adding -Name to change from outputting filesystem-info objects to strings unexpectedly causes these errors to be suppressed.
Steps to reproduce (on Windows)
Run the following Pester test:
Describe "Get-ChildItem: unlistable-directory test" {
BeforeAll {
Push-Location TestDrive:/
# Create a regular and an unlistable directory.
$null = New-Item -Type Directory someDir, someUnlistableDir
$acl = Get-Acl someUnlistableDir
$denyRule = New-Object System.Security.AccessControl.FileSystemAccessRule $env:USERNAME, ListDirectory, Deny
$acl.AddAccessRule($denyRule)
Set-Acl someUnlistableDir $acl
}
AfterAll {
# Make the unlistable directory listable again, so that removal of the temp. folder
# underlying TestDrive: doesn't fail.
$acl = Get-Acl someUnlistableDir
$acl.RemoveAccessRuleSpecific($denyRule)
Set-Acl someUnlistableDir $acl
Pop-Location
}
It "Get-ChildItem -Recurse complains about child directory that cannot be listed." {
(Get-ChildItem -Recurse -ErrorVariable err 2>$null).Name | Should -BeExactly someDir, someUnlistableDir
$err.Count | Should -Be 1
}
It "Get-ChildItem -Recurse -Name complains about child directory that cannot be listed." {
Get-ChildItem -Recurse -Name -ErrorVariable err 2>$null | Should -BeExactly someDir, someUnlistableDir
$err.Count | Should -Be 1
}
}Expected behavior
Both tests should pass.
Actual behavior
Executing script .....Tests.ps1
Describing Get-ChildItem: unlistable-directory test
[+] Get-ChildItem -Recurse complains about child directory that cannot be listed. 797ms
[-] Get-ChildItem -Recurse -Name complains about child directory that cannot be listed. 161ms
Expected 1, but got 0.
27: $err.Count | Should -Be 1
That is, adding -Name caused the inability to list the contents of someUnlistableDir to be quietly ignored.
Environment data
PowerShell Core 6.2.0-rc.1
Windows PowerShell v5.1.17134.590
Metadata
Metadata
Assignees
Labels
Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issuesWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Activity
iSazonov commentedon Jan 30, 2020
Will look after #11602
iSazonov commentedon Feb 14, 2020
Michael Klement (@mklement0) The cmdlet returns folders on which it writes an error. Should it includes unaccessable folders to result list or no? I'd expect no (yes, it will be a breaking change) that looks like more native.
Update: never mind - it is right behavior that we see in Explorer.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.