When I run Connect-AzAccount my default browser set on windows OS(Chrome) is not running. But instead it is loading IE and asking for login details. How to change the browser ?
2 Answers
At my company, we use MFA for our Azure AD account. Additionally, our local AD is not integrated with Azure AD. And to make it more challenging, we use our local AD account (first.last@company.com) to authenticate to Azure DevOps while we use our Azure AD account (first.last@admin.company.com) to authenticate to the Azure Resource Manager API.
Every time that I tried to authenticate with my Azure AD account (first.last@admin.company.com) in PowerShell with Connect-AzAccount
, it would authenticate as with my local AD account (first.last@company.com), instead.
I tried the usual commands to no avail:
Disconnect-AzAccount
Clear-AzContext -Scope CurrentUser -Force
Disable-AzContextAutosave -Scope Process
I tried nuking the history in Internet Explorer, but no dice.
I changed the default browser on my laptop from Chrome to Edge, and I nuked the history in Edge. No impact. PowerShell seemed to still be using its same engine for managing the interactive Azure login page regardless of what the OS is using for the default browser.
I researched how to change the browser used by PowerShell to manage the interactive Azure login page (Connect-AzAccount
) to work around the problem. But I didn't have any luck finding a solution.
Here's what ultimately worked in my scenario:
Disconnect-AzAccount
Connect-AzAccount -UseDeviceAuthentication
When you use the -UseDeviceAuthentication
option, Connect-AzAccount
lets you manually pick which browser you want to use for Azure authentication.
In my case, I used Chrome in incognito mode to perform Azure authentication, and I was finally able to authenticate with my Azure AD account ("first.last@admin.company.com") successfully.
Although this doesn't change the default browser used by Connect-AzAccount, it's a work-around to let you manually choose a different browser for Azure authentication.

- 30,962
- 25
- 85
- 135

- 398
- 3
- 9
-
Thanks Van for such detailed explain. I'm facing the exact same challenge as well, we too have normal account and a separated admin account to authenticate to the Azure Resource Manager. So just to be clear, When you use the `-UseDeviceAuthentication` option, `Connect-AzAccount` will print in the console, `To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code xxx to authenticate.`, then will confirm again with you in the browser you chose with _"Sign in You're signing in to Microsoft Azure PowerShell on another device"_, right? – xpt Sep 18 '21 at 00:20
-
1@xpt, that's correct. And once you complete the registration process in the browser of your choice, the Connect-AzCount authenticates you without further interaction. The process kind of reminds me of registering a Roku box with Amazon or Netflix. – Van Vangor Sep 18 '21 at 13:51
The pop-up window is not the default browser, only az login is used to log in through the browser.
In az login
, if you want to log in in any browser, log in through az login --use-device-code
.
In Connect-AzAccount
, the page opened by default is still the powershell tool, it is not a browser, the following gif can be clearly seen in the task manager.
Step 1. Run Connect-AzAccount
in powershell.
Step 2. Check Task Manager.
Suggestion
You can login azure without browser by
Connect-AzAccount -Credential $Credential -Tenant $tenant -Subscription $subscription
For more details, you can refer to the post.
Connect-AzAccount - how to avoid azure device authentication?

- 15,263
- 1
- 14
- 29
-
Hi Jason, where does the `az` come from? I tried the `az login` but got `az: The term 'az' is not recognized as a name of a cmdlet, function, script file, or executable program.` – xpt May 11 '21 at 21:30
-
1@xpt, the "az login" is an example of using Azure CLI where Connect-AzAccount is using PowerShell. – Van Vangor Sep 15 '21 at 22:51
-
Oh, thanks for the explanation @VanVangor. In this case, my problem still remains, as the `Connect-AzAccount -Credential $Credential -Tenant $tenant -Subscription $subscription` still involves MFA, and therefore still need to start the browser. The quoted answer has a prerequisite of _"make sure your account doesn't enable the MFA(Multi-Factor Authentication)"_ of which does not apply to my case, as it is our IT department that dictates the MFA requirement. Starting the powershell tool is worse, as if it starts a browser, at least I can save my PW in it. – xpt Sep 16 '21 at 14:11
-
@xpt, I'm using MFA, too, and my problem persisted, as well. I found a different work-around. I'll post it as an answer as soon as I get a few minutes. – Van Vangor Sep 17 '21 at 18:30
-