Private/Vault/Get-KeyFromVault.ps1
|
# Retrieve a key from the vault based on the provided key name function Get-KeyFromVault() { param( [Parameter(Mandatory=$true)] [string]$Key ) Unlock-Platform $plat = $env:CONSOLE_PLATFORM if ($plat -eq "MacOS") { $serviceKey = security find-generic-password -s $Key -w if ($LASTEXITCODE -ne 0) { return $null } } elseif ($plat -eq "Windows") { $serviceKey = [CredManager]::GetCreds($Key) } else { throw "Unsupported OS." } return $serviceKey } |