Copy secrets between Key Vaults

I had a requirement to setup POC environment for application migration to the cloud. When I looked at the number of secrets in the source POC KV setup I knew I cannot do this manually. So just used a couple of PowerShell commands to move the secrets between the Key Vault.


  • Azure PowerShell module installed
  • Access to Azure subscription
  • Access rights on Key Vault
  • Network access to Key Vault (In my case it was a private environment, so needed to make sure VPN setup in place to connect to Key Vault)
# Login to Azure


# Assign Key Vault  Names


# Get Source Key Vault Names

$sourceSecretList = (Get-AzKeyVaultSecret -VaultName $sourceVault).Name

# Create secret in target
Set-AzKeyVaultSecret -VaultName $destVault -Name $_ `
-SecretValue (Get-AzKeyVaultSecret -VaultName $sourceVault -Name $_).SecretValue

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s