Skip to content

Instantly share code, notes, and snippets.

@spawnrider
Created May 31, 2022 15:25
Show Gist options
  • Save spawnrider/c1c3c134d261d9678beeed793956dcfc to your computer and use it in GitHub Desktop.
Save spawnrider/c1c3c134d261d9678beeed793956dcfc to your computer and use it in GitHub Desktop.
Copying an Azure Key Vault using Powershell
Param(
[Parameter(Mandatory)]
[string]$sourceKvName,
[Parameter(Mandatory)]
[string]$destKvName
)
Connect-AzAccount
$secretNames = (Get-AzKeyVaultSecret -VaultName $sourceKvName).Name
$secretNames.foreach{
Set-AzKeyVaultSecret -VaultName $destKvName -Name $_ `
-SecretValue (Get-AzKeyVaultSecret -VaultName $sourceKvName -Name $_).SecretValue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment