Az.KeyVault Module Reference

This section provides detailed reference information for the cmdlets available in the Azure PowerShell Az.KeyVault module. These cmdlets allow you to manage Azure Key Vault secrets, certificates, and access policies using PowerShell.

Get-AzKeyVaultSecret

Retrieves a specific secret from an Azure Key Vault.

Syntax

Get-AzKeyVaultSecret -VaultName <String> -Name <String> [-Version <String>] [-AsPlainText] [-Context <AzureRmAccount>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]

Parameters

Name Description Type Required
-VaultName The name of the Key Vault. String Yes
-Name The name of the secret to retrieve. String Yes
-Version The version of the secret. If omitted, the latest version is retrieved. String No
-AsPlainText Specifies that the secret should be returned as plain text. Use with caution. Switch No

Example

Get-AzKeyVaultSecret -VaultName "MyKeyVault" -Name "MySecret"

Set-AzKeyVaultSecret

Creates or updates a secret in an Azure Key Vault.

Syntax

Set-AzKeyVaultSecret -VaultName <String> -Name <String> -SecretValue <SecureString> [-ContentType <String>] [-PassThru] [-Context <AzureRmAccount>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]

Parameters

Name Description Type Required
-VaultName The name of the Key Vault. String Yes
-Name The name of the secret. String Yes
-SecretValue The value of the secret, provided as a SecureString. SecureString Yes
-ContentType The content type of the secret. String No
-PassThru Returns the created or updated secret object. Switch No

Example

$secretValue = ConvertTo-SecureString "MySecretValue" -AsPlainText -Force
Set-AzKeyVaultSecret -VaultName "MyKeyVault" -Name "MyNewSecret" -SecretValue $secretValue

Remove-AzKeyVaultSecret

Deletes a specific secret from an Azure Key Vault.

Syntax

Remove-AzKeyVaultSecret -VaultName <String> -Name <String> [-Version <String>] [-InRemovedState] [-Force] [-PassThru] [-Context <AzureRmAccount>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]

Parameters

Name Description Type Required
-VaultName The name of the Key Vault. String Yes
-Name The name of the secret to delete. String Yes
-Version The version of the secret to delete. If omitted, the latest version is deleted. String No
-InRemovedState Releases a secret from the soft-delete state. Switch No
-Force Suppresses confirmation prompts. Switch No
-PassThru Returns the deleted secret object. Switch No

Example

Remove-AzKeyVaultSecret -VaultName "MyKeyVault" -Name "MySecretToDelete" -Force