Don’t you hate it when you want to logon to Azure and you need to select a subscription every time? Firstly, you need to logon using: “Connect-AzAccount”. After that, you need to select your subscription but you obviously don’t know your subscription id. You run: “Get-AzSubscription”, copy the subscription id and run: “Set-AzContext”. I have created a simple script where you can directly select your Azure Subscription at Logon via a menu.

This is the menu:

Azure Logon Subscription Menu

As you can see, I have 4 subscriptions and this way I can easily select the one I want to use at logon via Azure Powershell.

I will show you how it works!

Prerequisites

  • Microsoft Azure tenant + subscription(s)
  • Powershell Modules (install guide, please upgrade your Powershell to version 7.)
  • Optional: Powershell profile (creation guide)

Script syntax + explanation

This is the script syntax:

This is the explanation for the Azure logon subscription menu is as follows:

Firstly, save the Powershell script above as a .ps1 file.

After that run the file:

Azure Logon Subscription Menu - Start Function

After this, you are able to run the “AzureLogon” command:

An authentication prompt pops up and after that you are able to select your subscription:

Azure Logon Subscription Menu - fully functioning menu

In addition, I use Windows Terminal as my default command window. Check out how to install here.

Add the script to your Powershell profile

When you want to use this script more frequently I advise you to add this script to your Powershell profile. I have put the link to create a powershell profile in the prerequisites but here it is again.

After you created the Powershell profile you can put this powershell function directly in there.

That way, when Powershell starts, you are directly able to use this function and can easily logon to Azure Powershell:

References

Install Powershell modules

Create Powershell Profile

Other Posts:

AutoPilot device scope tag script with menu

Windows 10 Image Series

Related Posts

One thought on “Azure Logon Subscription Menu

Leave a Reply

Your email address will not be published. Required fields are marked *