I'm new to really using powershell, and just stumbled onto this. I can do
Get-ChildItem c:\windows -exclude Temp
and it works just fine. But running the same command on a root directory (e.g. c:\
, d:\
) will return nothing.
Get-ChildItem c:\ -exclude Temp
When I ran into this, I was baffled. At least one person has reported it as a "bug". My question is - is it really? Or is there some explanation for why this is "correct" behavior?
In searching for info on this problem, there is this where we find out -include
is subtly different than -exclude
in how it applies - though maybe it is at the root (no pun intended) of why the -exclude
behavior is different for root directories?
I can work around the problem in several different ways. I was just hoping someone who understands powershell thoroughly might shed some light on if the behavior of -exclude
on root directories really is a bug, or is somehow correct.