How to Force Connect-MgGraph to Prompt for Sign-In Every Time?
Asked by
Wandering_Cloud23
I'm using the command `Connect-MgGraph -ClientId "MyClientID" -TenantId "MyTenantID" -Scopes "UserAuthenticationMethod.ReadWrite.All" -NoWelcome` to connect to Microsoft Graph. Initially, it prompts me to enter my email and password, but now it logs me in automatically every time I run it. I want to be prompted for my credentials every time I connect. I know that running `Disconnect-MgGraph` can prompt me for my username if there's an active session, but if I close and open a new shell, it connects without asking for authentication. How can I ensure I'm prompted for my sign-in info each time?
Answers
Try using `Connect-MgGraph -ContextScope Process`. This will bypass the Windows Authentication Manager (WAM), which is likely caching your credentials. It's really helpful if you need to switch between multiple clients or sessions. You can even set this as your default using PSDefaultParameters.
Reply to this answer
Instead of using the options, you could just run `Connect-MgGraph` alone. But keep in mind, since you're using both ClientId and TenantId, this suggests that you're connecting to a tenant that's different from your logged-in user. So, this might not be the best route.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions