Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure PowerShell Connect-AzureAD and Login-AzureRmAccount

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?

like image 621
Gerhard Brueckl Avatar asked Aug 30 '17 08:08

Gerhard Brueckl


People also ask

How do I connect to a specific Azure subscription using PowerShell?

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.

How do I connect to a different subscription in PowerShell?

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 do I log into Azure command from PowerShell?

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.


1 Answers

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

like image 101
Gerhard Brueckl Avatar answered Nov 15 '22 05:11

Gerhard Brueckl