Skip to content

Get-Context

SYNOPSIS

Retrieves a context from the in-memory context vault.

SYNTAX

Get-Context [[-ID] <String[]>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Retrieves a context from the loaded contexts stored in memory. If no ID is specified, all available contexts will be returned. Wildcards are supported to match multiple contexts.

EXAMPLES

EXAMPLE 1

Get-Context

Output:

Repositories      : {@{Languages=System.Object[]; IsPrivate=False; Stars=130;
                    CreatedDate=2/9/2024 10:45:11 AM; Name=Repo2}}
AccessScopes      : {repo, user, gist, admin:org}
AuthToken         : MyFirstSuperSecretToken
TwoFactorMethods  : {TOTP, SMS}
IsTwoFactorAuth   : True
ApiRateLimits     : @{ResetTime=2/9/2025 11:15:11 AM; Remaining=4985; Limit=5000}
UserPreferences   : @{CodeReview=System.Object[]; Notifications=; Theme=dark; DefaultBranch=main}
SessionMetaData   : @{Device=Windows-PC; Location=; BrowserInfo=; SessionID=sess_abc123}
LastLoginAttempts : {@{Success=True; Timestamp=2/9/2025 9:45:11 AM; IP=192.168.1.101}, @{Success=False}}
ID                : GitHub/User-3
Username          : john_doe
LoginTime         : 2/9/2025 10:45:11 AM

Repositories      : {@{Languages=System.Object[]; IsPrivate=False; Stars=130;
                    CreatedDate=2/9/2024 10:45:11 AM; Name=Repo2}}
AccessScopes      : {repo, user, gist, admin:org}
AuthToken         : MySuperSecretToken
TwoFactorMethods  : {TOTP, SMS}
IsTwoFactorAuth   : True
ApiRateLimits     : @{ResetTime=2/9/2025 11:15:11 AM; Remaining=4985; Limit=5000}
UserPreferences   : @{CodeReview=System.Object[]; Notifications=; Theme=dark; DefaultBranch=main}
SessionMetaData   : @{Device=Windows-PC; Location=; BrowserInfo=; SessionID=sess_abc123}
LastLoginAttempts : {@{Success=True; Timestamp=2/9/2025 9:45:11 AM; IP=192.168.1.101}, @{Success=False}}
ID                : GitHub/User-8
Username          : jane_doe
LoginTime         : 2/9/2025 10:45:11 AM

Retrieves all contexts from the context vault (in memory).

EXAMPLE 2

Get-Context -ID 'MySecret'

Retrieves the context called 'MySecret' from the vault.

EXAMPLE 3

'My*' | Get-Context

Output:

ID        : MyConfig
Config    : {ConfigKey=ConfigValue}

ID        : MySecret
Key       : EncryptedValue
AuthToken : EncryptedToken
Favorite  : {Color=Blue; Number=7}

ID        : MySettings
Setting   : {SettingKey=SettingValue}
Config    : {ConfigKey=ConfigValue}
YourData  : {DataKey=DataValue}

Retrieves all contexts that start with 'My' from the context vault (in memory).

PARAMETERS

-ID

The name of the context to retrieve from the vault. Supports wildcards.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: *
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: True

-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

[System.Object]

NOTES

Returns a list of contexts matching the specified ID or all contexts if no ID is specified. Each context object contains its ID and corresponding stored properties.

https://psmodule.io/Context/Functions/Get-Context/