Here's the script I used to retrieve secrets from an Azure Key Vault.
Clear-Host
$VaultName = "your-vault-name"
Write-Output ""
$SearchName = Read-Host -prompt "Secret Name "
$secretName = $SearchName
$secretValue = $(Get-AzKeyVaultSecret -VaultName $VaultName -Name $secretName -AsPlainText)
Write-Output "$($secretName) | $($secretValue)"
I used to have this script searching the whole key vault using the -match operator based on a search string. But I have changed that since because it tries to access the key vault a lot which in the future might cause issues if we get some sort of auditing to the key vault resource. Also, I find it really slow to return anything when the key vault is fully populated with thousands of secrets.
No comments:
Post a Comment