Azure login and subscription choice

This code will login into Azure interactively and then give you a list of subscriptions your account has access to which when chosen will set your Azure context

#login to azure interactively
write-host "Logging into Azure, please check the open browser window to login to Azure"
Connect-AzAccount
#Clear-Host

#subscriptions
write-host "These are the Azure subscriptions you can work with"
Write-Host ""
$azSubs = Get-AzSubscription | Select-Object Name | Sort-Object name
foreach ( $azsub in $azSubs ) {
 Write-Host $azsub.name
}
Write-Host ""
$azSubChoice = Read-Host -Prompt 'Please enter the name of the subscription you want to work in'
Set-AzContext -Subscription $azSubChoice
Write-Host ""
Last modified July 21, 2024: update (e2ae86c)