How to ensure to be prompted for credentials every time I run Connect-AzAccount in PS

Alex Toniati 121 Reputation points
2023-10-09T15:33:17.3633333+00:00

Hi all,

How can I force powershell to ask me to input username and credential everytime that I run 'connect-azaccount' command?
I mean, if I log on azure using powershell then close, even after some days, I run the command 'connect-azaccount' again and is prompted to choose between 'Pick my previous/recents account' and 'Use another account'.

Thats the point, I need to be directly asked for the username and password and not to pick recents accounts.

Is there any solution for this case?

Thanks in advance

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,954 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
24,674 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 47,861 Reputation points
    2023-10-09T20:03:35.8166667+00:00

    Use the Disconnect-AzAccount cmdlet when you're finished. Or put that cmdlet into your PowerShell profile so it disconnects you every time you start PowerShell. Or put it into PowerShell script that runs when you log out of your widows session or shut down your machine.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.