Get-AzKeyVaultSecret
Gets the secrets in a key vault.
Syntax
ByVaultName (Default)
Get-AzKeyVaultSecret
[-VaultName] <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
BySecretName
Get-AzKeyVaultSecret
[-VaultName] <String>
[-Name] <String>
[[-Version] <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
BySecretVersions
Get-AzKeyVaultSecret
[-VaultName] <String>
[-Name] <String>
[-IncludeVersions]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
ByDeletedSecrets
Get-AzKeyVaultSecret
[-VaultName] <String>
[[-Name] <String>]
[-InRemovedState]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Get-AzKeyVaultSecret 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-AzKeyVaultSecret -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-AzKeyVaultSecret -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-AzKeyVaultSecret -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-AzKeyVaultSecret -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-AzKeyVaultSecret -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.
Example 6: Get all the secrets that have been deleted but not purged for this key vault.
PS C:\>Get-AzKeyVaultSecret -VaultName 'Contoso' -InRemovedState
This command gets all the secrets that have been previously deleted, but not purged, in the key vault named Contoso.
Example 7: Gets the secret ITSecret that has been deleted but not purged for this key vault.
PS C:\>Get-AzKeyVaultSecret -VaultName 'Contoso' -KeyName 'ITSecret' -InRemovedState
This command gets the secret ITSecret that has been previously deleted, but not purged, in the key vault named Contoso. This command will return metadata such as the deletion date, and the scheduled purging date of this deleted secret.
Parameters
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure
Parameter properties
Type: | IAzureContextContainer |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | AzContext, AzureCredential |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-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.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
BySecretVersions
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-InRemovedState
Specifies whether to show the previously deleted secrets in the output
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByDeletedSecrets
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Name
Specifies the name of the secret to get.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | SecretName |
Parameter sets
BySecretName
Position: | 1 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
BySecretVersions
Position: | 1 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | 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.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | 0 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-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.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | SecretVersion |
Parameter sets
BySecretName
Position: | 2 |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.