I can't seem to figure out how to climb up the directory and check each parent folder for an item. I.e., from where ever get-location is, I'd like to check (get-location).parent, and then check (get-location).parent.parent and etc. until I get back to the root, c:.
Here's what I've figured out so far, but it seems cumbersome and unwieldy. I get that to see if it exists, I should use something like:
test-path (get-item $t).Parent.Parent
but that won't climb up the directory tree like I want, and I can't grok how to get it to work in combination with Split-Path...
I thought something like:
$p = split-path $(get-location) -Parent
if ( (split-path $p -leaf) -eq "test" ) {
$q = $(Split-Path $p -parent )
} elseif ( (split-path $q -leaf) -eq "test") {
$r = (split-path $q -leaf) -eq "test"
}
might work, but it's not as recursive as I'd like it to be.