# List all Key Vaults in the subscriptionazkeyvaultlist# List Key Vaults in a specific Resource Groupazkeyvaultlist--resource-group<ResourceGroupName># Show details of a specific Key Vaultazkeyvaultshow--name<KeyVaultName># If accessPolicies, you can see them here# List all keys in a Key Vaultazkeyvaultkeylist--vault-name<KeyVaultName># List all secrets in a Key Vaultazkeyvaultsecretlist--vault-name<KeyVaultName># Get versions of a secretazkeyvaultsecretlist-versions--vault-name<KeyVaultName>--name<SecretName># List all certificates in a Key Vaultazkeyvaultcertificatelist--vault-name<KeyVaultName># List all deleted Key Vaults in the subscriptionazkeyvaultlist-deleted# Get properties of a deleted Key Vaultazkeyvaultshow-deleted--name<KeyVaultName># Get assigned rolesaz role assignment list --include-inherited --scope "/subscriptions/<subscription-uuid>/resourceGroups/<resource-group>/providers/Microsoft.KeyVault/vaults/<vault-name>"
# Get secret valueazkeyvaultsecretshow--vault-name<KeyVaultName>--name<SecretName># Get old versions secret valueazkeyvaultsecretshow--idhttps://<KeyVaultName>.vault.azure.net/secrets/<KeyVaultName>/<idOldVersion>
# Get keyvault tokencurl "$IDENTITY_ENDPOINT?resource=https://vault.azure.net&api-version=2017-09-01"-H secret:$IDENTITY_HEADER# Connect with PS AzureAD## $token from management APIConnect-AzAccount -AccessToken $token -AccountId 1937ea5938eb-10eb-a365-10abede52387 -KeyVaultAccessToken $keyvaulttoken
# Get details of a specific Key VaultGet-AzKeyVault-VaultName <KeyVaultName># List all keys in a Key VaultGet-AzKeyVaultKey-VaultName <KeyVaultName># List all secrets in a Key VaultGet-AzKeyVaultSecret-VaultName <KeyVaultName># List all certificates in a Key VaultGet-AzKeyVaultCertificate-VaultName <KeyVaultName># List all deleted Key Vaults in the subscriptionGet-AzKeyVault-InRemovedState# Get properties of a deleted Key VaultGet-AzKeyVault-VaultName <KeyVaultName>-InRemovedState# Get secret valuesGet-AzKeyVaultSecret-VaultName <vault_name>-Name <secret_name>-AsPlainText
#!/bin/bash# Dump all keyvaults from the subscription# Define Azure subscription IDAZ_SUBSCRIPTION_ID="your-subscription-id"# Specify the filename for outputCSV_OUTPUT="vault-names-list.csv"# Login to Azure accountazlogin# Select the desired subscriptionazaccountset--subscription $AZ_SUBSCRIPTION_ID# Retrieve all resource groups within the subscriptionAZ_RESOURCE_GROUPS=$(azgrouplist--query"[].name"-otsv)# Initialize the CSV file with headersecho"Vault Name,Associated Resource Group"> $CSV_OUTPUT# Iterate over each resource groupfor GROUP in $AZ_RESOURCE_GROUPSdo# Fetch key vaults within the current resource groupVAULT_LIST=$(azkeyvaultlist--resource-group $GROUP --query"[].name"-otsv)# Process each key vaultfor VAULT in $VAULT_LISTdo# Extract the key vault's nameVAULT_NAME=$(azkeyvaultshow--name $VAULT --resource-group $GROUP --query"name"-otsv)# Append the key vault name and its resource group to the fileecho"$VAULT_NAME,$GROUP">> $CSV_OUTPUTdonedone