Set-​Azure​Rm​Context

Sets the tenant, subscription, and environment for cmdlets to use in the current session.

Syntax

Set-AzureRmContext
   -Context <PSAzureContext>
   [-Confirm]
   [-WhatIf]
   [<CommonParameters>]
Set-AzureRmContext
   [-SubscriptionId <String>]
   [-TenantId <String>]
   [-Confirm]
   [-WhatIf]
   [<CommonParameters>]
Set-AzureRmContext
   [-SubscriptionName <String>]
   [-TenantId <String>]
   [-Confirm]
   [-WhatIf]
   [<CommonParameters>]

Description

The Set-AzureRmContext cmdlet sets authentication information for cmdlets that you run in the current session. The context includes tenant, subscription, and environment information.

Examples

Example 1: Set the subscription context

PS C:\>Set-AzureRmContext -SubscriptionId "xxxx-xxxx-xxxx-xxxx"

Account      : PFuller@contoso.com
Environment  : AzureCloud
Subscription : xxxx-xxxx-xxxx-xxxx
Tenant       : yyyy-yyyy-yyyy-yyyy

This command sets the context to use the specified subscription.

Required Parameters

-Context

Specifies the context for the current session.

Type:PSAzureContext
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Optional Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

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

Specifies the subscription ID for the context that this cmdlet sets for the current session.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-SubscriptionName

Specifies the subscription name for the context that this cmdlet sets for the current session.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-TenantId

Specifies the ID of the tenant for for the context that this cmdlet sets for the current session.

Type:String
Aliases:Domain
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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:False
Accept pipeline input:False
Accept wildcard characters:False

Outputs

PSAzureContext