We recently found ourselves needing to copy over every single secret (name and value) from one Azure KeyVault to a newly created one. I found ways to restore the secrets from a backup, but we didn't have a backup. Is there a Powershell script that can just loop through every name/value combo in a source vault and copy it to a destination vault?
Azure Keyvault – Copy All Secrets Using PowerShell
azureazure-keyvaultpowershell
Best Answer
this is just too triggering (no offense), here's a more "powershelly" version:
Just to sum it up:
Parameters are mandatory with this change and you can tab complete them, so you dont have to remember which one is first.
Using
foreach
is a bit cleaner than usingdo\while
(certainly less cognitive effort).You dont have to cast values to text and encrypt it back, you can just use encrypted value to assign it to new secret