You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Get-ChildItem ignores the -Depth parameter when -Include or -Exclude are specified #3726
All 3 commands should output the same number - the count of items in the current dir.
Actual behavior
The 1st command reports the number of items in the current directory only.
The 2nd and 3rd commands unexpectedly traverse the entire subtree, ignoring -Depth 0.
Environment data
PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on macOS 10.12.4
PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Microsoft Windows 10 Pro (64-bit; v10.0.14393)
Given that I spent longer than I care to admit being tripped up by this this morning, I figure it couldn't hurt to add a comment on this issue in support of sorting it.
To my mind I see two potential courses of action:
Make Include/Exclude and Depth mutually exclusive. Not intuitive, but at least the user will get an error rather than unexpected results.
Adjust the cmdlet so that using these combinations of parameters works as one would expect them to.
I'd say the second one is more desirable, but I'm approaching this from a high-level as a user so I don't fully appreciate the amount of work or if it would result in any breaking changes.
The same behavior in 5.1.15063.608. Get-ChildItem -Depth 0 -Filter 'mask' works good, but Get-ChildItem -Depth 0 -Include 'mask' returns all 'mask' elemens of tree.
Activity
Windos commentedon Aug 30, 2017
Given that I spent longer than I care to admit being tripped up by this this morning, I figure it couldn't hurt to add a comment on this issue in support of sorting it.
To my mind I see two potential courses of action:
I'd say the second one is more desirable, but I'm approaching this from a high-level as a user so I don't fully appreciate the amount of work or if it would result in any breaking changes.
psmolkin commentedon Sep 15, 2017
The same behavior in 5.1.15063.608.
Get-ChildItem -Depth 0 -Filter 'mask'works good, butGet-ChildItem -Depth 0 -Include 'mask'returns all 'mask' elemens of tree.jszabo98 commentedon Apr 5, 2024
This is still true to this day in powershell 5.1 (5.1.19041.4170).