< Back

Set-AzureRmContext

Tue Jan 29, 2019 9:59 pm

NAME Set-AzureRmContext



SYNOPSIS

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





SYNTAX

Set-AzureRmContext [-Context] <PSAzureContext> [-DefaultProfile <IAzureContextContainer>] [-ExtendedProperty

<System.Collections.Generic.IDictionary`2[System.String,System.String]>] [-Force] [-Name <String>] [-Scope {Process | CurrentUser}] [-Confirm]

[-WhatIf] [<CommonParameters>]



Set-AzureRmContext [-Subscription] <String> [-DefaultProfile <IAzureContextContainer>] [-ExtendedProperty

<System.Collections.Generic.IDictionary`2[System.String,System.String]>] [-Force] [-Name <String>] [-Scope {Process | CurrentUser}] [-Tenant

<String>] [-Confirm] [-WhatIf] [<CommonParameters>]



Set-AzureRmContext [-SubscriptionObject] <PSAzureSubscription> [-DefaultProfile <IAzureContextContainer>] [-ExtendedProperty

<System.Collections.Generic.IDictionary`2[System.String,System.String]>] [-Force] [-Name <String>] [-Scope {Process | CurrentUser}] [-Confirm]

[-WhatIf] [<CommonParameters>]



Set-AzureRmContext [-DefaultProfile <IAzureContextContainer>] [-ExtendedProperty

<System.Collections.Generic.IDictionary`2[System.String,System.String]>] [-Force] [-Name <String>] [-Scope {Process | CurrentUser}] -Tenant

<String> [-Confirm] [-WhatIf] [<CommonParameters>]



Set-AzureRmContext [-TenantObject] <PSAzureTenant> [-DefaultProfile <IAzureContextContainer>] [-ExtendedProperty

<System.Collections.Generic.IDictionary`2[System.String,System.String]>] [-Force] [-Name <String>] [-Scope {Process | CurrentUser}] [-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.





PARAMETERS

-Context <PSAzureContext>

Specifies the context for the current session.



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-DefaultProfile <IAzureContextContainer>

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



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-ExtendedProperty <System.Collections.Generic.IDictionary`2[System.String,System.String]>

Additional context properties



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Force [<SwitchParameter>]

Overwrite the existing context with the same name, if any.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Name <String>

Name of the context



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Scope <ContextModificationScope>

Determines the scope of context changes, for example, whether changes apply only to the current process, or to all sessions started by this

user.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Subscription <String>

Subscription Name or Id



Required? true

Position? 0

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-SubscriptionObject <PSAzureSubscription>

A subscription object



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-Tenant <String>

Tenant name or ID



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-TenantObject <PSAzureTenant>

A Tenant Object



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-Confirm [<SwitchParameter>]

Prompts you for confirmation before running the cmdlet.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]

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



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

PSAzureContext

Parameter 'Context' accepts value of type 'PSAzureContext' from the pipeline





OUTPUTS

PSAzureContext







NOTES









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.







RELATED LINKS

Online Version: https://docs.microsoft.com/en-us/powers ... ermcontext

Get-AzureRmContext