Skip to content

Set-KeyVaultKey

Azure: Sets or updates a Key Vault key

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

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

	[Parameter(Mandatory = $false)]
	[ValidateSet('Software', 'HSM')]
	[string]$Destination = 'Software'
)

try {
	Import-Module Az.KeyVault -ErrorAction Stop
	$key = Add-AzKeyVaultKey -VaultName $VaultName -Name $Name -Destination $Destination -ErrorAction Stop
	Write-Output $key
} catch {
	Write-Error $_
	exit 1
}

The name of the Key Vault.

The name of the key.

The destination for the key (Software or HSM).

An interactive directory of PowerShell scripts.