Edit

Share via


Enable-AzContextAutosave

Azure contexts are PowerShell objects representing your active subscription to run commands against, and the authentication information needed to connect to an Azure cloud. With Azure contexts, Azure PowerShell doesn't need to reauthenticate your account each time you switch subscriptions. For more information, see Azure PowerShell context objects.

This cmdlet allows the Azure context information to be saved and automatically loaded when you start a PowerShell process. For example, when opening a new window.

Syntax

Default (Default)

Enable-AzContextAutosave
    [-Scope <ContextModificationScope>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

Allows the Azure context information to be saved and automatically loaded when a PowerShell process starts. The context is saved at the end of the execution of any cmdlet that affects the context. For example, any profile cmdlet. If you're using user authentication, then tokens can be updated during the course of running any cmdlet.

Examples

Example 1: Enable autosaving credentials for the current user

Turn on credential autosave for the current user. Whenever a PowerShell window is opened, your current context is remembered without logging in.

Enable-AzContextAutosave

Example 2

Allow the Azure credential, account, and subscription information, to be saved and automatically loaded when you open a PowerShell window in this PowerShell session. (autogenerated)

Enable-AzContextAutosave -Scope Process

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
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

-DefaultProfile

The credentials, tenant, and subscription used for communication with Azure

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Scope

Determines the scope of context changes. For example, whether changes apply only to the current process, or to all sessions started by this user. Changes made with the scope CurrentUser will affect all PowerShell sessions started by the user. If a particular session needs to have different settings, use the scope Process.

Parameter properties

Type:ContextModificationScope
Default value:CurrentUser
Accepted values:Process, CurrentUser
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
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:None
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

ContextAutosaveSettings