Set-AzureRmContext
Sets the tenant, subscription, and environment for cmdlets to use in the current session.
Note
The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.
The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.
Set-AzureRmContext
[-SubscriptionName <String>]
[-TenantId <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzureRmContext
-Context <PSAzureContext>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzureRmContext
[-TenantId <String>]
[-SubscriptionId <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
The Set-AzureRmContext cmdlet sets authentication information for cmdlets that you run in the current session. The context includes tenant, subscription, and environment information.
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.
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the context for the current session.
Type: | PSAzureContext |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the subscription ID for the context that this cmdlet sets for the current session.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the subscription name for the context that this cmdlet sets for the current session.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the ID of the tenant for the context that this cmdlet sets for the current session.
Type: | String |
Aliases: | Domain |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
PSAzureContext