with this structure folder :
TEST\
ok.txt
[_]\
a.txt
and the code :
clear
$rep="TEST"
$regex="*"
Get-ChildItem -Path $rep -recurse -Include $regex | ForEach-Object {
"FullName: $($_.FullName) & mode: $($_.Mode)"
Test-Path -Path $_.FullName -PathType Leaf
Test-Path -Path $_.FullName -PathType Container
"_________"
}
I get
FullName: ***\TEST\[_] & mode: d-----
False
False
_________
FullName: ***\TEST\[_]\a.txt & mode: -a----
False
False
_________
FullName: ***\TEST\ok.txt & mode: -a----
True
False
_________
Conclusion :
[] directory : not recognize as Container
[]\a.txt : not recognize as Leaf
but give for both the type Mode (d----- & -a----)
How can I use Leaf & Container to get at least one True ?