In this article I’ll guide you how to change the azure subscription using PowerShell, we can use the command Select-AZSubscription and this Changes the current and default Azure subscriptions. When you use this command, you can use either the subscription ID, Subscription Name, or the Tenant ID.
- You can query with the Subscription Name
Select-AzSubscription -SubscriptionName 'James Eduard Lab'
2. or you can query with With TenantID
Select-AzSubscription -Tenant 'XXXX-XXXXX-XXXXXXX-XXXX'
3. With Subscription ID
Select-AzSubscription -SubscriptionId 'XXXX-XXXXX-XXXXXXX-XXXX'
It takes some time to display the result on console it will display one or more subscriptions.
In that case, you can switch to the other subscription using these commands Set-AZContext
Sets the tenant, subscription, and environment for cmdlets to use in the current session. Command and you can use subscription ID or Name for it.
Query via Subscription ID:
Set-AzContext -SubscriptionId "xxxx-xxxx-xxxx-xxxx"
Query via Subscription Name:
Set-AzContext -SubscriptionName "James Eduard Lab"