aboutsummaryrefslogtreecommitdiff
path: root/scripts/findFileRecursivelyUp.ps1
blob: 4b6409e8cfd77d81d3cebd58814c778ac7eb1fc4 (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 for $filename"
    $currentDir = Split-path $currentDir -Parent
}
Write-Verbose "Examining $currentDir for $filename - Found"
return $currentDir