List all secrets with plain text from a key vault

Viewed 5364

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
2 Answers

You just need to create a loop around secrets:

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

With a newer version of Az modules.

To see both a name and value for each secret stored in the Azure KeyVault, you can try this out:

    $secrets=Get-AzKeyVaultSecret -VaultName 'vaultName'
    $secrets | % {Write-Output "$($_.name) $($(Get-AzKeyVaultSecret -VaultName $_.VaultName -Name $_.Name).SecretValueText)" }
Related