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

[SecretManagement] Register-SecretVault - Non terminating if vault exists #92

Description

@itfranck

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions