Set-Context¶
SYNOPSIS¶
Set a context and store it in the context vault.
SYNTAX¶
Set-Context [[-ID] <String>] [[-Context] <Object>] [-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 cached in memory for faster access. This function ensures that the context is securely stored using encryption mechanisms.
EXAMPLES¶
EXAMPLE 1¶
Set-Context -ID 'PSModule.GitHub' -Context @{ Name = 'MySecret' }
Output:
ID : PSModule.GitHub
Path : C:\Vault\Guid.json
Context : @{ Name = 'MySecret' }
Creates a context called 'MySecret' in the vault.
EXAMPLE 2¶
Set-Context -ID 'PSModule.GitHub' -Context @{ Name = 'MySecret'; AccessToken = '123123123' }
Output:
ID : PSModule.GitHub
Path : C:\Vault\Guid.json
Context : @{ Name = 'MySecret'; AccessToken = '123123123' }
Creates a context called 'MySecret' in the vault with additional settings.
EXAMPLE 3¶
$context = @{ ID = 'MySecret'; Name = 'SomeSecretIHave'; AccessToken = '123123123' }
$context | Set-Context
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
-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.