Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Multiple Azure users/context in PowerShell
# Connect to Azure specifying a tenant
# If you want to connect to multiple tenants, you can connect multiple times.
Connect-AzAccount -tenantId
# adding a new PowerShell Azure context
# setting a friendly name to allow for easy switching.
Set-AzContext -name "Subscription 1 in tenant 1" -SubscriptionId "31ffbc99-4cbf-43b2-8789-ba8d73171e70" -tenantid
Set-AzContext -name "Subscription 2 in tenant 1" -SubscriptionId "b5c85827-0afd-49a0-8923-8fe35cfa8dd0" -tenantid
# check the current context
# Get all contexts available
Get-AzContext -ListAvailable
#Switch between the contexts available
Select-AzContext 'Subscription 1 in tenant 1'
#Clear all contexts/log out
Clear-AzContext -force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.