aboutsummaryrefslogtreecommitdiff
path: root/scripts/findFileRecursivelyUp.ps1
blob: 788adbf08ce6373b6159f222d0fa0fe953e5cb7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[CmdletBinding()]
param(
    [ValidateNotNullOrEmpty()]
    [Parameter(Mandatory=$true)][string]$startingDir,
    [ValidateNotNullOrEmpty()]
    [Parameter(Mandatory=$true)][string]$filename
)

$ErrorActionPreference = "Stop"
$currentDir = $startingDir

while (!($currentDir -eq "") -and !(Test-Path "$currentDir\$filename"))
{
    Write-Verbose "Examining: $currentDir"
    $currentDir = Split-path $currentDir -Parent
}
Write-Verbose "Found: $currentDir"
return $currentDir