AL/Get-CredentialFromEnvironmentJson.ps1
<#
.Synopsis Gets the credential from settings.json .Description Gets credentials from settings.json .Parameter SourcePath Path to the current project .Example $secureCred = Get-CredentialFromEnvironmentJson #> function Get-CredentialFromEnvironmentJson { param ( # Source path containing environment.json [Parameter(Mandatory=$false)] [string] $SourcePath = (Get-Location) ) if ((Get-EnvironmentKeyValue -SourcePath $SourcePath -KeyName 'password') -eq '') { return $false } return New-Object System.Management.Automation.PSCredential((Get-EnvironmentKeyValue -SourcePath $SourcePath -KeyName 'user'), (ConvertTo-SecureString (Get-EnvironmentKeyValue -SourcePath $SourcePath -KeyName 'password') -AsPlainText -Force)) } |