Edit

Share via


Set-SecretInfo

Adds or replaces additional secret metadata to a secret currently stored in a vault.

Syntax

NameParameterSet (Default)

Set-SecretInfo
    [-Name] <String>
    [-Metadata] <Hashtable>
    [[-Vault] <String>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

InfoParameterSet

Set-SecretInfo
    [-Metadata] <Hashtable>
    -InputObject <SecretInformation>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

This cmdlet adds additional secret metadata to an existing secret. Metadata support is an optional feature for an extension vault. The command throws an error if a vault doesn't support secret metadata. Metadata is a Hashtable object containing Name/Value pairs. The metadata is stored unencrypted. You shouldn't store sensitive information in the metadata.

Examples

Example 1

Set-SecretInfo -Name Secret1 -Vault Vault1 -Metadata @{
    Expiration = ([datetime]::new(2022, 5, 1))
}
Get-SecretInfo -Name Secret1 -Vault Vault1 |
    Select-Object Name,Metadata
Name         Metadata
----         --------
Secret1 {[Expiration, 5/1/2022 12:00:00 AM]}

This example adds metadata to the Secret1 secret stored in Vault1 vault. Get-SecretInfo retrieves the metadata for Secret1 to show the added metadata.

Example 2

Set-SecretInfo -Name Secret2 -Vault Vault2 -Metadata @{
    Expiration = ([datetime]::new(2022, 5, 1))
}
Set-SecretInfo: Can't set secret metadata Secret2. Vault Vault2 doesn't support secret metadata.

This example adds metadata to the Secret2 secret stored in Vault2 vault. However, Vault2 does not support metadata. The command fails and returns an error.

Example 3

Get-SecretInfo -Name Secret3 |
    Set-SecretInfo -Metadata @{ Created = (Get-Date) }

This example pipes a SecretInformation object to the Set-SecretInfo command and adds metadata to the associated secret.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-InputObject

This parameter takes a SecretInformation object that defines the secret to be updated.

Parameter properties

Type:Microsoft.PowerShell.SecretManagement.SecretInformation
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

InfoParameterSet
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Metadata

Specifies a Hashtable containing key-value pairs to associate with the secret in the vault. The specified extension vault may not support secret metadata. If the vault doesn't support metadata, the operation fails and returns an error. The values of any metadata in the hashtable must be one of the following types:

  • string
  • int
  • DateTime

Metadata isn't stored securely in a vault. Metadata shouldn't contain sensitive information.

Parameter properties

Type:Hashtable
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

NameParameterSet
Position:1
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False
System.Collections.Hashtable
Position:1
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

Specifies the name of the secret to add metadata to. Wildcard characters (*) aren't permitted.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

NameParameterSet
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Vault

Specifies the name of the vault containing the secret to add or update the metadata for. Wildcard characters (*) aren't permitted. By default, this cmdlet looks for the secret in the current user's default vault.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

NameParameterSet
Position:2
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet isn't run.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
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.

Inputs

Hashtable

Outputs

None