I have a PowerShell script which uses Connect-AzureAD and also Login-AzureRmAccount. Even though both use the same credentials, I get asked to enter them twice. Is there any way to only prompt the user once and use the same credentials for both cmdlets?
To add an authenticated account for use with Service Management, use the Add-AzureAccount cmdlet from the Azure PowerShell module. If no context is found for the current user, the user's context list is populated with a context for each of their first 25 subscriptions.
To change the azure subscription using PowerShell, we can use the Select-AZSubscription command. When you use this command, you can use either the subscription ID, Subscription Name, or the Tenant ID.
How to sign into the Azure CLI. Before using any Azure CLI commands with a local install, you need to sign in with az login. Run the login command. If the CLI can open your default browser, it will initiate authorization code flow and open the default browser to load an Azure sign-in page.
This finally worked for me
$cred = Get-Credential
Login-AzureRmAccount -Credential $cred
Connect-AzureAD -Credential $cred
it does not display the neat Microsoft login screen but works for my scenarios
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With