Get-Secret
Finds and returns a secret by name from registered vaults.
Syntax
NameParameterSet (Standardwert)
Get-Secret
[-Name] <String>
[[-Vault] <String>]
[-AsPlainText]
[<CommonParameters>]
InfoParameterSet
Get-Secret
[-InputObject] <SecretInformation>
[-AsPlainText]
[<CommonParameters>]
Beschreibung
This cmdlet finds and returns the first secret that matches the provided name. If a vault name is specified, only that vault is searched. Otherwise, it searches all vaults and returns the first matching result. If the vault registry has a default vault, the cmdlet searches that vault before any other registered vault. Secrets that are String or SecureString types are returned as SecureString objects by default.
Beispiele
Example 1
Get-Secret -Name Secret1 -Vault CredMan
Get-Secret -Name Secret1 -Vault CredMan -AsPlainText
System.Security.SecureString
PlainTextSecretString
This example searches for a secret with the name Secret1
, which is a String type secret. The
first command returns the secret as a SecureString object. The second command uses the
AsPlainText parameter to return the secret as a String object instead, displaying in the
console as plain text.
Example 2
Get-SecretInfo -Name Secret2 -Vault SecretStore |
Get-Secret -AsPlainText
This example retrieves secret information for the secret named Secret2
in the vault named
SecretStore
. It then sends the result through the pipeline to Get-Secret
, which searches for the
secret and returns it as plain text.
Parameter
-AsPlainText
Specifies that a secret whose type is String or SecureString should be returned as a String (in plain text) instead of a SecureString. If the secret being retrieved isn't a String or SecureString, this parameter has no effect.
Caution
To ensure security, you should avoid using plaintext strings whenever possible.
Parametereigenschaften
Typ: | SwitchParameter |
Standardwert: | False |
Unterstützt Platzhalter: | False |
Nicht anzeigen: | False |
Parametersätze
(All)
Position: | Named |
Obligatorisch.: | False |
Wert aus Pipeline: | False |
Wert aus Pipeline nach dem Eigenschaftsnamen: | False |
Wert aus verbleibenden Argumenten: | False |
-InputObject
Specifies a SecretInformation object representing a vault secret instead of specifying the
Name and Vault parameters. You can get a SecretInformation object with the
Get-SecretInfo
cmdlet.
Parametereigenschaften
Typ: | Microsoft.PowerShell.SecretManagement.SecretInformation |
Standardwert: | None |
Unterstützt Platzhalter: | False |
Nicht anzeigen: | False |
Parametersätze
InfoParameterSet
Position: | 0 |
Obligatorisch.: | True |
Wert aus Pipeline: | True |
Wert aus Pipeline nach dem Eigenschaftsnamen: | False |
Wert aus verbleibenden Argumenten: | False |
-Name
Specifies the name of the secret to retrieve. Wildcard characters aren't permitted.
Parametereigenschaften
Typ: | String |
Standardwert: | None |
Unterstützt Platzhalter: | False |
Nicht anzeigen: | False |
Parametersätze
NameParameterSet
Position: | 0 |
Obligatorisch.: | True |
Wert aus Pipeline: | True |
Wert aus Pipeline nach dem Eigenschaftsnamen: | False |
Wert aus verbleibenden Argumenten: | False |
-Vault
Specifies the name of the registered vault to retrieve the secret from. If no vault name is specified, then all registered vaults are searched. If the vault registry has a default vault and this parameter isn't specified, then the default vault is searched before the other registered vaults.
Parametereigenschaften
Typ: | String |
Standardwert: | None |
Unterstützt Platzhalter: | False |
Nicht anzeigen: | False |
Parametersätze
NameParameterSet
Position: | 1 |
Obligatorisch.: | False |
Wert aus Pipeline: | False |
Wert aus Pipeline nach dem Eigenschaftsnamen: | False |
Wert aus verbleibenden Argumenten: | 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.