Save-AzureRmContext

Saves the current authentication information for use in other PowerShell sessions.

Important

Because Az PowerShell modules now have all the capabilities of AzureRM PowerShell modules and more, we'll retire AzureRM PowerShell modules on 29 February 2024.

To avoid service interruptions, update your scripts that use AzureRM PowerShell modules to use Az PowerShell modules by 29 February 2024. To automatically update your scripts, follow the quickstart guide.

Syntax

Save-AzureRmContext
    [[-Profile] <AzureRmProfile>]
    [-Path] <String>
    [-Force]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The Save-AzureRmContext cmdlet saves the current authentication information for use in other PowerShell sessions.

Examples

Example 1: Saving the current session's context

PS C:\> Add-AzureRmAccount
PS C:\> Save-AzureRmContext -Path C:\test.json

This example saves the current session's Azure context to the JSON file provided.

Example 2: Saving a given context

PS C:\> Save-AzureRmContext -Profile (Add-AzureRmAccount) -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.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DefaultProfile

The credentials, tenant, and subscription used for communication with azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Force

Overwrite the given file if it exists

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Path

Specifies the path of the file to which to save authentication information.

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-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.

Type:Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile
Position:0
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.Azure.Commands.Common.Authentication.Models.AzureRMProfile

Outputs

Microsoft.Azure.Commands.Profile.Models.PSAzureProfile