Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Save-AzContext
- Module:
- Az.Accounts Module
Saves the current authentication information for use in other PowerShell sessions.
Syntax
Default (Default)
Save-AzContext
[[-Profile] <AzureRmProfile>]
[-Path] <String>
[-Force]
[-WithCredential]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Save-AzContext cmdlet saves the current authentication information for use in other PowerShell sessions.
Examples
Example 1: Saving the current session's context
Connect-AzAccount
Save-AzContext -Path C:\test.json
This example saves the current session's Azure context to the JSON file provided.
Example 2: Saving a given context
Save-AzContext -Profile (Connect-AzAccount) -Path C:\test.json
This example saves the Azure context that is passed through to the cmdlet to the JSON file provided.
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
-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
-Force
Overwrite the given file if it exists
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Path
Specifies the path of the file to which to save authentication information.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Profile
Specifies the Azure context from which this cmdlet reads. If you do not specify a context, this cmdlet reads from the local default context.
Parameter properties
| Type: | AzureRmProfile |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | wi |
Parameter sets
-WithCredential
Export the credentials to the file
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
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
AzureRmProfile
Outputs
PSAzureProfile
Azure PowerShell
Feedback
Was this page helpful?
