Title: Adding -Name to Get-ChildItem -Recurse quietly ignores directories it isn't permitted to list · Issue #9122 · PowerShell/PowerShell · GitHub
Open Graph Title: Adding -Name to Get-ChildItem -Recurse quietly ignores directories it isn't permitted to list · Issue #9122 · PowerShell/PowerShell
X Title: Adding -Name to Get-ChildItem -Recurse quietly ignores directories it isn't permitted to list · Issue #9122 · PowerShell/PowerShell
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 strin...
Open Graph 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 out...
X 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...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/9122
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Adding -Name to Get-ChildItem -Recurse quietly ignores directories it isn't permitted to list","articleBody":"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`.\r\n\r\nSimply adding `-Name` to change from outputting filesystem-info objects to strings unexpectedly causes these errors to be suppressed.\r\n\r\n# Steps to reproduce (on Windows)\r\n\r\nRun the following Pester test:\r\n\r\n```powershell\r\nDescribe \"Get-ChildItem: unlistable-directory test\" {\r\n BeforeAll {\r\n Push-Location TestDrive:/\r\n # Create a regular and an unlistable directory.\r\n $null = New-Item -Type Directory someDir, someUnlistableDir\r\n $acl = Get-Acl someUnlistableDir\r\n $denyRule = New-Object System.Security.AccessControl.FileSystemAccessRule $env:USERNAME, ListDirectory, Deny\r\n $acl.AddAccessRule($denyRule)\r\n Set-Acl someUnlistableDir $acl\r\n }\r\n AfterAll {\r\n # Make the unlistable directory listable again, so that removal of the temp. folder\r\n # underlying TestDrive: doesn't fail.\r\n $acl = Get-Acl someUnlistableDir\r\n $acl.RemoveAccessRuleSpecific($denyRule)\r\n Set-Acl someUnlistableDir $acl \r\n Pop-Location\r\n }\r\n \r\n It \"Get-ChildItem -Recurse complains about child directory that cannot be listed.\" {\r\n (Get-ChildItem -Recurse -ErrorVariable err 2>$null).Name | Should -BeExactly someDir, someUnlistableDir\r\n $err.Count | Should -Be 1\r\n }\r\n\r\n It \"Get-ChildItem -Recurse -Name complains about child directory that cannot be listed.\" {\r\n Get-ChildItem -Recurse -Name -ErrorVariable err 2>$null | Should -BeExactly someDir, someUnlistableDir\r\n $err.Count | Should -Be 1\r\n }\r\n \r\n}\r\n```\r\n\r\n# Expected behavior\r\n\r\nBoth tests should pass.\r\n\r\n\r\n# Actual behavior\r\n\r\n```none\r\nExecuting script .....Tests.ps1\r\n\r\n Describing Get-ChildItem: unlistable-directory test\r\n [+] Get-ChildItem -Recurse complains about child directory that cannot be listed. 797ms\r\n [-] Get-ChildItem -Recurse -Name complains about child directory that cannot be listed. 161ms\r\n Expected 1, but got 0.\r\n 27: $err.Count | Should -Be 1\r\n```\r\n\r\nThat is, adding `-Name` caused the inability to list the contents of `someUnlistableDir` to be _quietly ignored_.\r\n\r\n# Environment data\r\n\r\n```none\r\nPowerShell Core 6.2.0-rc.1\r\nWindows PowerShell v5.1.17134.590\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-03-11T22:59:15Z","url":"https://github.com/PowerShell/PowerShell/issues/9122"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:30d85c79-e988-d8f6-a543-ba5a9f0f1fb8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA30:3BBE40:620F3:8B231:6AFD48EB |
| html-safe-nonce | 4386333b425c109a6c8850c6931c2326a8a43bd55ad08fb9d5c56063a1ccdf38 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTMwOjNCQkU0MDo2MjBGMzo4QjIzMTo2QUZENDhFQiIsInZpc2l0b3JfaWQiOiI4OTkzOTgxNjM2NDE2NDU2OTM5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b5ad2dc0a448d9a4fbbf6b88abe0396b59dd27a20fa9067ac98a96246fc4964b |
| hovercard-subject-tag | issue:419723630 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/9122/issue_layout |
| twitter:image | https://opengraph.githubassets.com/26e01be580151bd63dfb19b8fb2022de8e07a03099df03b6ac48d95b2fcaeec5/PowerShell/PowerShell/issues/9122 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/26e01be580151bd63dfb19b8fb2022de8e07a03099df03b6ac48d95b2fcaeec5/PowerShell/PowerShell/issues/9122 |
| og:image:alt | 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 out... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | bdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 556dd37bb0aceffb25724e151b5d858b3265b40b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width