Get-​Azure​Key​Vault​Secret

Gets the secrets in a key vault.

Syntax

Get-AzureKeyVaultSecret
   [-VaultName] <String>
   [-Name] <String>
   [-IncludeVersions]
   [<CommonParameters>]
Get-AzureKeyVaultSecret
   [-VaultName] <String>
   [-Name] <String>
   [[-Version] <String>]
   [<CommonParameters>]

Description

The Get-AzureKeyVaultSecret cmdlet gets secrets in a key vault. This cmdlet gets a specific secret or all the secrets in a key vault.

Examples

Example 1: Get all current versions of all secrets in a key vault

PS C:\>Get-AzureKeyVaultSecret -VaultName 'Contoso'

This command gets the current versions of all secrets in the key vault named Contoso.

Example 2: Get all versions of a specific secret

PS C:\>Get-AzureKeyVaultSecret -VaultName 'Contoso' -Name 'ITSecret' -IncludeVersions

This command gets all versions of the secret named ITSecret in the key vault named Contoso.

Example 3: Get the current version of a specific secret

PS C:\>Get-AzureKeyVaultSecret -VaultName 'Contoso' -Name 'ITSecret'

This command gets the current version of the secret named ITSecret in the key vault named Contoso.

Example 4: Get a specific version of a specific secret

PS C:\>Get-AzureKeyVaultSecret -VaultName 'Contoso' -Name 'ITSecret' -Version '6A12A286385949DB8B5F82AFEF85CAE9'

This command gets a specific version of the secret named ITSecret in the key vault named Contoso.

Example 5: Get the plain text value of the current version of a specific secret

PS C:\>$secret = Get-AzureKeyVaultSecret -VaultName 'Contoso' -Name 'ITSecret'
PS C:\> Write-Host "Secret Value is: " $secret.SecretValueText

These commands get the current version of a secret named ITSecret, and then displays the plain text value of that secret.

Required Parameters

-IncludeVersions

Indicates that this cmdlet gets all versions of a secret. The current version of a secret is the first one on the list. If you specify this parameter you must also specify the Name and VaultName parameters.If you do not specify the IncludeVersions parameter, this cmdlet gets the current version of the secret with the specified Name.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Name

Specifies the name of the secret to get.

Type:String
Aliases:SecretName
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-VaultName

Specifies the name of the key vault to which the secret belongs. This cmdlet constructs the fully qualified domain name (FQDN) of a key vault based on the name that this parameter specifies and your current environment.

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-Version

Specifies the secret version. This cmdlet constructs the FQDN of a secret based on the key vault name, your currently selected environment, the secret name, and the secret version.

Type:String
Aliases:SecretVersion
Position:3
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Inputs

String

Outputs

List<Microsoft.Azure.Commands.KeyVault.Models.Secret>, Microsoft.Azure.Commands.KeyVault.Models.Secret