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
Get-ChildItem $PSHOME -Recurse -Exclude * # implies -Path $PSHOME
Get-ChildItem -LiteralPath $PSHOME -Recurse -Exclude *
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
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)
Even without using wildcards,
Get-ChildItem -Recurseallows matching items on every level of the target hierarchy, possibly filtered with-Includeand-Exclude.However, if you use
-LiteralPathrather than the (implied)-Pathparameter,-Includeand-Excludeare 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/-Excludegetting ignored should be issued, or a separate parameter set should prevent combining-LiteralPathwith-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