Skip to content

Set-KeyVaultSecret

Azure: Sets or updates a Key Vault secret

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

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

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

try {
	Import-Module Az.KeyVault -ErrorAction Stop
	$secureSecret = ConvertTo-SecureString -String $SecretValue -AsPlainText -Force
	$secret = Set-AzKeyVaultSecret -VaultName $VaultName -Name $Name -SecretValue $secureSecret -ErrorAction Stop
	
	rite-Output "Successfully set secret '$Name' in vault '$VaultName'."
}
catch {
	Write-Error $_
	exit 1
}

The name of the Key Vault.

The name of the secret.

The plaintext value of the secret.

An interactive directory of PowerShell scripts.