How to select or check the current subscription in the PowerShell session?
In previous article we saw how to securely connect to Azure by importing subscription file into our local machine.
In this article we will see
So, let’s see how to list the subscriptions that we have installed on the local PC. So, we’re going to use the Get-AzureSubscription cmdlet to do that, and we can also pipe the results through to the select cmdlets just to filter them by subscription name in the case that we might have a lot of subscriptions installed on the PC.
In PowerShell prompt on the management PC I am going to type Get-AzureSubscription, and that will show all the subscriptions that I have installed on this particular PC. As you can see there, I have two, and the important piece of information I need is the subscription name, which is Pay-As-You-Go
Alternatively, I could have piped the results into the select cmdlets and just listed the subscriptions by subscription name.
To select the currently active subscription in the PowerShell console, I use the Select-AzureSubscription cmdlets and all I need to do is add the SubscriptionName, which is Pay-As-You-Go. Alternatively, I can add the default switch to this cmdlets, and what that does is set Pay-As-You-Go to the subscription that will always be selected any time I start a new PowerShell session.
I’m going to type that command into the prompt there, and as you can see, that has been successful with no error message.
So I can check the configuration by using the Get-AzureSubscription cmdlet to see what is the default or what is the current subscription. So, in PowerShell command if I type Get-AzureSubscription and I want to know what the current subscription is, you can see Pay-As-You-Go is now set as the current subscription and any cmdlets I run now will run against that particular subscription.
To conclude, in this article we have learned how to list the Azure subscriptions on the local machine, and once the subscription is set, how to select the current and default subscription, how to check the current and default subscriptions currently configured in PowerShell.
Number of Views:1244