I've often used a construct similar to this (using aliases for brevity):
gci -ad | %{$_ | gci}
which works fine. But when trying to help another user on this forum, I found that the following doesn't work:
gci -ad | %{$_.Parent | gci}
throws the following error for each iteration:
gci : Cannot find path 'C:\Users\keith\Documents\Documents' because it does not exist.
At line:1 char:25
+ gci -ad | %{$_.Parent | gci}
+ ~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\keith\Documents\Documents:Stri
ng) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemC
ommand
even though:
gci -ad | %{$_.GetType() -eq $_.Parent.GetType()}
produces a scrennfull of True
.
I'm pretty sure it has something to do with parameter binding, but would like to understand the apparent inconsistancy....