To change Azure subscription in PowerShell, we can simply use the Select-AZSubscription Azure PowerShell cmdlet. It’s really easy to use.
Table of Contents
Azure Powershell change subscription
Well, let’s discuss how to change Azure subscription using PowerShell. As part of this topic, we will discuss the Select-AZSubscription Azure PowerShell cmdlet and its implementation.
Select-AZSubscription is an excellent Azure PowerShell cmdlet that can be used to change the Azure subscription.
Let’s discuss the syntax of the Select-AZSubscription Azure PowerShell cmdlet along with Examples that will give you enough idea to change your Azure subscription with PowerShell.
You can change or set the Azure subscription with the help of the Subscription Name parameter.
Select-AzSubscription -SubscriptionName 'The name of your subscription'
Below is the example where Visual Studio Enterprise is the name of my Azure subscription
Select-AzSubscription -SubscriptionName 'Visual Studio Enterprise'
Once you will execute the above Azure PowerShell cmdlet, you will get the output like below.
PS C:\WINDOWS\system32> Select-AzSubscription -SubscriptionName 'Visual Studio Enterprise' Name Account Subscriptio Environmen TenantId nName t ---- ------- ----------- ---------- -------- Visual Studio Enterprise (1cdf4300-de... fewlines... Visual S... AzureCloud 5d9d690...
You can also use the Subscription Id as parameter to change the Azure subscription.
Select-AzSubscription -SubscriptionId 'Your Azure Subscription Id'
1cdf4300-xxxx-4518-6c6c-xxxxxxxxxxxx is my Azure subscription Id.
Select-AzSubscription -SubscriptionId '1cdf4300-dee5-4518-9c9c-feaa72a5cbd1'
once you will execute the above Azure PowerShell cmdlet, you will get the same output as below
Another syntax is to use Azure TenantID to change Azure subscription
Select-AzSubscription -Tenant 'your tenantId'
5d9d690a-0310-474d-xxxx-xxxxxxxxxxxxx is the tenant Id for me.
Select-AzSubscription -Tenant '5d9d690a-0310-474d-xxxx-xxxxxxxxxxxxx'
If you will execute the above Azure PowerShell cmd, you will get the execute as below
When you have more than one active Azure subscription you can even use Set-AzContext to change the other Azure subscription.
You may also like following the below articles
- Azure AD sign-in logs PowerShell
- How to find Resource id in Azure portal
- Azure PowerShell Get VM Public IP
- How To Open Azure PowerShell
- How To Create PowerShell Azure Function
- How to Upload and Download File From Azure Blob Storage Using C# and PowerShell
Well, it’s simple and we discussed How to change Azure subscription using PowerShell using Select-AZSubscription Azure PowerShell cmdlet.