Skip to content

Set-Context

SYNOPSIS

Set a context in a context vault.

SYNTAX

__AllParameterSets

Set-Context [[-ID] <string>] [[-Context] <Object>] [-Vault] <string> [-PassThru] [-WhatIf]
 [-Confirm] [<CommonParameters>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

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

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: System.Management.Automation.SwitchParameter
DefaultValue: ''
SupportsWildcards: false
Aliases:
- cf
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Context

The data of the context.

Type: System.Object
DefaultValue: '@{}'
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 1
  IsRequired: false
  ValueFromPipeline: true
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ID

The ID of the context.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 0
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-PassThru

Pass the context through the pipeline.

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Vault

The name of the vault to store the context in.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 2
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-WhatIf

Runs the command in a mode that only reports what would happen without performing the actions.

Type: System.Management.Automation.SwitchParameter
DefaultValue: ''
SupportsWildcards: false
Aliases:
- wi
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

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

System.Object

{{ Fill in the Description }}

OUTPUTS

[PSCustomObject]

{{ Fill in the Description }}

System.Management.Automation.PSObject

{{ Fill in the Description }}

NOTES

Returns an object representing the stored or updated context. The object includes the ID, path, and securely stored context information.