I use the following line in my script to return all the paths of all folders at the $folder
location.
dir -recurse $folder|?{$_.PSIsContainer}|select -ExpandProperty FullName
This works. But: I only need the fourth element of each path.
I've tried adding |{$_.Split("\")}[3]}
with the [3]
in various places but I am getting an error with the split command, that Expressions are only allowed as the first element of a pipeline.
I've tried putting brackets around various sections, and putting the whole expression into brackets and into a split but I can't seem to find a way to attach the split to any part of the pipe... Is there another way, perhaps?