AL/Get-EnvironmentKeyValue.ps1
function Get-EnvironmentKeyValue { Param( [Parameter(Mandatory=$false)] [string]$SourcePath = (Get-Location), [Parameter(Mandatory=$true)] [string]$KeyName ) if (!(Test-Path (Join-Path $SourcePath 'settings.json'))) { return '' } $JsonContent = Get-Content (Join-Path $SourcePath 'settings.json') -Raw $Json = ConvertFrom-Json $JsonContent if ($null -ne $Json.PSObject.Properties.Item($KeyName)) { try { $Json.PSObject.Properties.Item($KeyName).Value } catch { throw "Could not find value for $KeyName in settings.json" } } else { return '' } } Export-ModuleMember Get-EnvironmentKeyValue |