AL/Get-EnvironmentKeyValue.ps1
<# .Synopsis Retrieves a value from the settings.json .Description Retrieves the value for the speficied key from the project's settings.json .Parameter SourcePath Path to the current project .Parameter KeyName Name of the key .Example $value = Get-EnvironmentKeyValue -SourcePath "C:\Install" -KeyName "locale" #> # REMOVE IN FUTURE RELEASE # function Get-EnvironmentKeyValue { Param( [Parameter(Mandatory=$false)] [string]$SourcePath = (Get-Location), [Parameter(Mandatory=$true)] [string]$KeyName ) $token = "" if (Test-Path (Join-Path $SourcePath 'settings.json')) { $JsonContent = Get-Content (Join-Path $SourcePath 'settings.json') -Raw $Json = ConvertFrom-Json $JsonContent if ($null -ne $Json.PSObject.Properties.Item($KeyName)) { try { $token = $Json.PSObject.Properties.Item($KeyName).Value } catch { $token = '' } } else { $token = '' } } $token } Export-ModuleMember Get-EnvironmentKeyValue |