共用方式為


Set-SecretInfo

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

語法

NameParameterSet (預設值)

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.

範例

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.

參數

-Confirm

Prompts you for confirmation before running the cmdlet.

參數屬性

類型:SwitchParameter
預設值:False
支援萬用字元:False
不要顯示:False
別名:cf

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-InputObject

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

參數屬性

類型:Microsoft.PowerShell.SecretManagement.SecretInformation
預設值:None
支援萬用字元:False
不要顯示:False

參數集

InfoParameterSet
Position:Named
必要:True
來自管線的值:True
來自管線按屬性名稱的值:False
來自剩餘引數的值: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.

參數屬性

類型:Hashtable
預設值:None
支援萬用字元:False
不要顯示:False

參數集

NameParameterSet
Position:1
必要:True
來自管線的值:True
來自管線按屬性名稱的值:False
來自剩餘引數的值:False
System.Collections.Hashtable
Position:1
必要:True
來自管線的值:True
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-Name

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

參數屬性

類型:String
預設值:None
支援萬用字元:False
不要顯示:False

參數集

NameParameterSet
Position:0
必要:True
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值: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.

參數屬性

類型:String
預設值:None
支援萬用字元:False
不要顯示:False

參數集

NameParameterSet
Position:2
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-WhatIf

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

參數屬性

類型:SwitchParameter
預設值:False
支援萬用字元:False
不要顯示:False
別名:wi

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值: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.

輸入

Hashtable

輸出

None