I want to retrieve a secret value from key vault in text using powershell. To achieve this I am using:
(Get-AzKeyVaultSecret -VaultName 'vault_name' -Name 'secret_name').SecretValueText
But for some reason this is returing null value. What am I doing wrong and how to overcome this?
CodePudding user response:
You can use the below cmdlet, to retrieve the key vault secret from PowerShell as suggested in
CodePudding user response:
I found a way to convert the secret value to plain text using Powershell which worked for me:
$fetch=(Get-AzKeyVaultSecret -VaultName 'vault_name' -Name 'secret_name')
$value=$fetch.SecretValue
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($value)
$PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
Write-Host $PlainPassword