I'm guessing that one of those paths does not exists. Get-ChildItem has a few counter-intuitive behaviours. It may be a mix of interpreting the input, legacy functionality and maybe a bug or two.
If you don't use -Recurse
, you'll get Cannot find path ...
error as expected.
It will also work properly if you add backslashes to paths:
Get-ChildItem -Path c:Test1, c:Test2 -Filter *.xmd -Recurse -File
or use -LiteralPath
(-Path
accepts wildcards):
Get-ChildItem -LiteralPath c:Test1, c:Test2 -Filter *.xmd -Recurse -File
Add -ErrorAction Continue
or -ErrorAction SilentlyContinue
if you don't want execution to stop at missing path error.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…