There is a very good description on how to login using PowerShell at Different ways to login to Azure automation using PowerShell (sqlshack.com)
To select the correct subscription use
Get-AzSubscription -SubscriptionName "{name}" | Select-AzSubscription