Selecting the right Subscription in PowerShell

When your organization has multiple Azure Subscriptions and you are entitled to work with them, selecting the correct subscription becomes an important thing to do.

Different approaches exist. I will have a look at the two most straight forward ones.

Using an argument to Connect-AzAccount

Connect-AzAccount holds specific attributes than can help you, namely SubscriptionName or SubscriptionId. If you know the Subscription name you want to connect to, issuing the following command directly connects to the correct subscription, after which you can start scripting:

Connect-AzAccount -SubscriptionName "Microsoft Partner Network"

To check to which subscription is linked, the command Get-AzContext can be issued.

Switching to another subscription in an active session

Switching to another Azure Subscription in an active session is also possible. This can be achieved by issuing the following command:

Set-AzContext -Subscription  or 

Useful PowerShell references

Jente Paredis

Jente Paredis

I am an experienced architect with a strong focus on Security, Identity & Productivity Solutions . I specialize in Azure AD, M365, and Azure Infrastructure Solutions. Throughout my professional career, I have had the pleasure to work with bright-minded people. I care deeply about both People and Technology.

Contact?

Dat kan vandaag nog!

 

Ik sta voor de combinatie van flexibiliteit en passie.

Hierdoor ben ik vaker dan een gemiddeld bedrijf bereikbaar om te helpen met jouw IT-gerelateerd project, probleem of vraagstuk!

Contact

Waarom jentech?

Expert Consultancy

Met meer dan 15 jaar ervaring in zowel KMO-omgevingen als multinationals, is jentech dé betrouwbare partner voor al jouw IT vraagstukken!

Microsoft Training

Expertise opbouwen, up-to-date houden én delen zit in mijn DNA. Ik hecht dan ook véél belang aan het behalen van relevante Microsoft certificaten.

Samenwerking

Ik ben er rotsvast van overtuid dat de combinatie van mijn expertise en jouw inzichten tot een onklopbare samenwerking leidt!

Visie

Ik wil mensen en organisaties helpen om hun eigen doelstellingen te halen door kwalitatieve IT-oplossingen aan te bieden.