Search code examples
azurepowershellazure-powershellazure-keyvault

List all secrets with plain text from a key vault


I know that you could get the plain text for a specific secret in azure key vault with a command like this:

$a = Get-AzureKeyVaultSecret -VaultName MyKeyVaultName -Name "SecretName"
$a.SecretValueText

But is it possible to list all secrets and the plain text value? This just shows a blank string for the secret value:

Get-AzureKeyVaultSecret -VaultName MyKeyVaultName | Select-Object Name,SecretValueText

Solution

  • You just need to create a loop around secrets:

    $q = Get-AzureKeyVaultSecret -VaultName 'xxx'
    $q.foreach{ Get-AzureKeyVaultSecret -VaultName $_.VaultName -Name $_.Name }.SecretValueText