Set-Context¶
SYNOPSIS¶
Set a context in a context vault.
SYNTAX¶
Set-Context [[-ID] <String>] [[-Context] <Object>] [-Vault] <String> [-PassThru]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION¶
If the context does not exist, it will be created. If it already exists, it will be updated. The context is encrypted and stored on disk. If the context vault does not exist, it will be created.
EXAMPLES¶
EXAMPLE 1¶
Set-Context -ID 'MyUser' -Context @{ Name = 'MyUser' } -Vault 'MyModule'
Output:
ID : MyUser
Path : C:\Vault\Guid.json
Context : @{ Name = 'MyUser' }
Creates a context called 'MyUser' in the 'MyModule' vault.
EXAMPLE 2¶
$context = @{
ID = 'MySecret'
Name = 'SomeSecretIHave'
AccessToken = '123123123' | ConvertTo-SecureString -AsPlainText -Force
}
$context | Set-Context
Output:
ID : MyUser
Path : C:\Vault\Guid.json
Context : {
ID = MySecret
Name = MyUser
AccessToken = System.Security.SecureString
}
Sets a context using a hashtable object.
PARAMETERS¶
-ID¶
The ID of the context.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Context¶
The data of the context.
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: @{}
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-Vault¶
The name of the vault to store the context in.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-PassThru¶
Pass the context through the pipeline.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-WhatIf¶
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Confirm¶
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction¶
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters¶
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS¶
OUTPUTS¶
[PSCustomObject]¶
NOTES¶
Returns an object representing the stored or updated context. The object includes the ID, path, and securely stored context information.