Edit

Share via


Set-SecretVaultDefault

Sets the provided vault name as the default vault for the current user.

Syntax

NameParameterSet (Default)

Set-SecretVaultDefault
    [-Name] <String>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

SecretVaultParameterSet

Set-SecretVaultDefault
    [-SecretVault] <SecretVaultInfo>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ClearParameterSet

Set-SecretVaultDefault
    [-ClearDefault]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

This cmdlet updates the vault registry to set the provided vault name as the default vault. Only one registered vault can be the default vault.

Examples

Example 1

PS C:\> Get-SecretVault

VaultName  ModuleName                        IsDefaultVault
---------  ----------                        --------------
CredMan    Microsoft.PowerShell.CredManStore False
LocalStore Microsoft.PowerShell.SecretStore  True

PS C:\> Set-SecretVaultDefault -Name CredMan
PS C:\> Get-SecretVault

VaultName  ModuleName                        IsDefaultVault
---------  ----------                        --------------
CredMan    Microsoft.PowerShell.CredManStore True
LocalStore Microsoft.PowerShell.SecretStore  False

PS C:\> Set-SecretVaultDefault -ClearDefault
PS C:\> Get-SecretVault

VaultName  ModuleName                        IsDefaultVault
---------  ----------                        --------------
CredMan    Microsoft.PowerShell.CredManStore False
LocalStore Microsoft.PowerShell.SecretStore  False

This example shows how to set and unset the default vault for the current user. The first command gets information about all registered vaults and shows that the LocalStore is the default vault for the user. The second command makes the CredMan vault the default vault. The third command shows that the CredMan vault is now default, and LocalStore vault is no longer default. The fourth command uses the ClearDefault parameter to remove the default designation from any registered vault. The last command shows that there is no default vault.

Parameters

-ClearDefault

Sets the IsDefault property to $false for all registered vaults.

Parameter properties

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

Parameter sets

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

-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

-Name

Specifies the name of a registered vault to set as the default vault. Wildcard characters (*) are not permitted.

Parameter properties

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

Parameter sets

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

-SecretVault

Specifies a SecretVaultInfo object representing the registered vault to set as the default vault.

Parameter properties

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

Parameter sets

SecretVaultParameterSet
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
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

None

Outputs

None