This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Description
Register-SecretVault - Non terminating if vault exists
It could be useful if vault already existing was not a terminating error when calling Register-SecretVault.
To achieve that currently, I have to include in my script (that use remove vault) the following.
$VaultParams = @{
Name = 'CICD-Azkeyvault'
ModuleName = 'Az.KeyVault'
VaultParameters = @{ AZKVaultName = 'cicd-key01'; SubscriptionId = '111111-11111-3333-4444-1p030450' }
}
# Method 1
if ($null -eq (Get-SecretVault -Name $VaultParams.Name)) {
Register-SecretVault @VaultParams
}
#Or
try {Register-SecretVault @VaultParams}catch {}
With the proposing non-terminating error change, simply ignoring the already exist non-terminating error using :
Register-SecretVault @VaultParams -ErrorAction SilentlyContinue
would be enough.