Skip to content

Backup-KeyVaultSecret

Azure: Backs up a Key Vault secret

param(
	[Parameter(Mandatory = $true)]
	[string]$VaultName,

	[Parameter(Mandatory = $true)]
	[string]$Name,

	[Parameter(Mandatory = $true)]
	[string]$OutputFile
)

try {
	Import-Module Az.KeyVault -ErrorAction Stop
	Backup-AzKeyVaultSecret -VaultName $VaultName -Name $Name -OutputFile $OutputFile -ErrorAction Stop
	Write-Output "Successfully backed up secret '$Name' to '$OutputFile'."
} catch {
	Write-Error $_
	exit 1
}

The name of the Key Vault.

The name of the secret to back up.

The path to save the backup file.

An interactive directory of PowerShell scripts.