core/private/Find-JaxConfigLine.ps1
|
function Find-JaxConfigLine { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string] $Path, [Parameter(Mandatory = $true)] [string] $KeyPath ) $commonParams = Get-JaxCommonParameters -BoundParameters $PSBoundParameters Write-Debug "FUNC: $($MyInvocation.MyCommand.Name) Args: $($PSBoundParameters | ConvertTo-Json -Depth 1 -Compress -WarningAction SilentlyContinue)" if (-not (Test-Path -Path $Path -PathType Leaf)) { return $null } $leafKey = $KeyPath.Split('.')[-1] $lines = Get-Content -Path $Path -ErrorAction SilentlyContinue if ($null -eq $lines) { return $null } for ($i = 0; $i -lt $lines.Count; $i++) { if ($lines[$i] -match "^\s*${leafKey}\s*:") { return ($i + 1) } } return $null } |