Get-ChildItem -Recurse shouldn't quietly ignore -Include and -Exclude when -LiteralPath is used instead of -Path #3730
Labels
Issue-Discussion
the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif
Resolution-Fixed
The issue is fixed.
WG-Cmdlets-Management
cmdlets in the Microsoft.PowerShell.Management module
Milestone
Even without using wildcards,
Get-ChildItem -Recurse
allows matching items on every level of the target hierarchy, possibly filtered with-Include
and-Exclude
.However, if you use
-LiteralPath
rather than the (implied)-Path
parameter,-Include
and-Exclude
are quietly ignored:If there's a good reason for this behavior (none that I'm aware of), then at the very least a warning about
-Include
/-Exclude
getting ignored should be issued, or a separate parameter set should prevent combining-LiteralPath
with-Include
/-Exclude
.Steps to reproduce
Expected behavior
Both calls should yield no output, because all items should be excluded by virtue of
-Exclude *
.Actual behavior
The 2nd command, due to
-Exclude *
getting ignored, outputs the entire subtree of$PSHOME
.Environment data
The text was updated successfully, but these errors were encountered: