Bird
0
0

You want to switch your Azure PowerShell session to a different tenant and subscription. Which sequence of commands is correct?

hard📝 Application Q9 of 15
PowerShell - Cross-Platform PowerShell
You want to switch your Azure PowerShell session to a different tenant and subscription. Which sequence of commands is correct?
ASet-AzContext -TenantId <tenantId>; Connect-AzAccount -Subscription <subscriptionId>
BConnect-AzAccount -Subscription <subscriptionId>; Set-AzContext -TenantId <tenantId>
CConnect-AzAccount -TenantId <tenantId>; Set-AzContext -Subscription <subscriptionId>
DSet-AzContext -Subscription <subscriptionId>; Connect-AzAccount -TenantId <tenantId>
Step-by-Step Solution
Solution:
  1. Step 1: Understand Connect-AzAccount and Set-AzContext roles

    Connect-AzAccount logs in and can specify tenant. Set-AzContext switches subscription context after login.
  2. Step 2: Determine correct order

    You must connect first with tenant info, then set subscription context.
  3. Final Answer:

    Connect-AzAccount -TenantId <tenantId>; Set-AzContext -Subscription <subscriptionId> -> Option C
  4. Quick Check:

    Login with tenant, then set subscription = Connect-AzAccount -TenantId ; Set-AzContext -Subscription [OK]
Quick Trick: Connect first with tenant, then set subscription context [OK]
Common Mistakes:
  • Reversing command order
  • Using Set-AzContext before login

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes