I believe the problem is that your loop variable is foreach $item.name . What you want is a loop variable called $item , and you will get access to the name property for each of them.
those.
foreach ($item in $path) { $item.name }
Also note that I left $item.name . In Powershell, if the result is not stored in a variable, redirected to another command, or otherwise committed, it is included in the return value of the function.
jpmc26
source share