Repository navigation
Closed
Labels
Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-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-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Description
Steps to reproduce
Get-ChildItem -Path *.txt -Recurse -Force -NameIn a folder with for example
S:\play\dir-demo> tree /f
Folder PATH listing for volume Source
Volume serial number is E68B-B87E
S:.
│ File.txt
│
├───sub1
│ │ File.txt
│ │
│ ├───subsub1
│ │ File.txt
│ │
│ └───subsub2
│ File.txt
│
├───sub2
│ File.txt
│
└───sub3
File.txt
Expected behavior
Relative paths to all text files found in subdirectories of the current directory.
Actual behavior
S:\play\dir-demo> Get-ChildItem -Path *.txt -Recurse -Force -Name
File.txt
Environment data
Name Value
---- -----
PSVersion 6.1.3
PSEdition Core
GitCommitId 6.1.3
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
(also reproduces on inbox 5.1.17763.316)
Metadata
Metadata
Assignees
Labels
Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-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-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Activity
mithrandir commentedon Feb 28, 2019
You can remove
-path *.txtSteveL-MSFT commentedon Feb 28, 2019
-Nameshould be able to use with-Pathsince they are not mutually exclusive. The problem appears to be here. Basically, when-Nameis used, what's happening is that if the result is a directory, it will recurse into the results of matching with-Path. So maybe the fix here is in documentation. To get the behavior you want:If you want to specify a starting path to recurse:
rainersigwald commentedon Feb 28, 2019
What would change in the documentation?
My understanding was that this
combined with
implied that the pattern could be specified as the
-Pathparameter and would be recursed. I'm not sure I see a straightforward way to correct that (but maybe I'm just missing it).SteveL-MSFT commentedon Feb 28, 2019
I think the description of
-Namein the documentation would be changed to reflect the current coded behavior which is when-Nameis specified, the results of-Pathfilter is used for recursion. If you use a filter like-Path *.txtand there isn't a folder ending in.txt, no recursion will occur.mklement0 commentedon Mar 3, 2019
Steve Lee (@SteveL-MSFT):
I don't think that's the right fix for the baffling inconsistency of the following two commands not targeting the same set of files:
Clearly, the intent of
-Nameis to only modify the type of the objects output - (relative) path strings instead of filesystem-info objects.That it changes what filesystem items are targeted should be considered a bug.
SteveL-MSFT commentedon Mar 11, 2019
Michael Klement (@mklement0), I agree that the current behavior is not correct, however, the question is whether it meets our breaking change bar
mklement0 commentedon Mar 11, 2019
Understood, but given that the current behavior is both obscure and unhelpful, it's hard to imagine that anyone actually relies on it, which makes fixing this a Bucket 3: Unlikely Grey Area change.
mklement0 commentedon Mar 11, 2019
P.S.: It looks like
-Namedeserves more scrutiny:Performance problem: -Name slows down Get-ChildItem -Recurse #9119
Get-ChildItem -Name adds provider NoteProperty members, Get-ChildItem -Name -Recurse does not #9120
Adding -Name to Get-ChildItem -Recurse quietly ignores directories it isn't permitted to list #9122
Get-ChildItem -Name and Get-ChildItem -Include / -Exclude unexpectedly follow symlinks with -Recurse #9126
SteveL-MSFT commentedon Mar 13, 2019
@PowerShell/powershell-committee reviewed this, we don't believe this is a Bucket 3 item as it's likely users are relying on this in simple cases where they did not encounter the counter behavior. We agree that
-Nameshould not change the behavior ofGet-ChildItem -Recurse -Path *.txtoutside of the output. However, due to the risks of the change, we propose that we should update the documentation to reflect the current behavior and pend any code change to a future FileSystemProvider v2 where-Namemay not even be needed. If users want the expected behavior, use the pipeline.Related #5785
1 remaining item
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.