Wildcards in the middle of a path don't work in Get-ChildItem with -Recurse and -File #21564
Open
5 tasks done
Labels
Issue-Bug
Issue has been identified as a bug in the product
Issue-Enhancement
the issue is more of a feature request than a bug
Needs-Triage
The issue is new and needs to be triaged by a work group.
WG-Cmdlets-Management
cmdlets in the Microsoft.PowerShell.Management module
Prerequisites
Steps to reproduce
On a standard installation of Windows (with Powershell 7.4.2), running the following two commands:
results in the same output, for example on my machine:
If, on the other hand, a part of the path is replaced with an asterisk, the two commands return different output:
i.e. the command
Get-ChildItem -Path 'C:\Windows\System32\*rivers\etc\*' -Recurse -File
wrongfully returns nothing.Note that passing only
-Recurse
without-File
correctly returns all of the files in theetc
directory.Expected behavior
Actual behavior
PS> Get-ChildItem -Path 'C:\Windows\System32\*rivers\etc\*' -Recurse -File
Error details
No response
Environment data
Visuals
No response
Workaround
It's possible to workaround the issue by using
| Where-Object { !$_.PSIsContainer }
instead of-File
The text was updated successfully, but these errors were encountered: