Why does Connect-MgGraph use the default browser in PowerShell 7 instead of the built-in one?
Asked by
TechyNinja42
I'm curious why the Connect-MgGraph command launches the default web browser when I'm using PowerShell 7. In PowerShell 5, it opens the built-in browser, which is much more convenient for me. I have multiple accounts for different tenants that I access occasionally, and I prefer not having them cluttering my main browser. I rely on the advancements and speed of PowerShell 7, but I'm wondering if there's a way to make it work within PowerShell 5 instead. Alternatively, is there a method to make Connect-MgGraph utilize the built-in PowerShell browser, instead of my system's default web browser?
Answers
You could just grab the URL from the default browser and paste it into your favorite browser. It's a simple workaround, although it might slow you down a bit.
Reply to this answer
Unfortunately, it seems like you can't force Connect-MgGraph to use the built-in mini-browser with PowerShell 7. One useful tip, though, is to set up app registrations for authentication, which avoids the pop-up window altogether.
ScriptingSavant20: Exactly! Especially if you're working with multiple tenants. I've set up some app registrations for running M365 reporting scripts, and it's made things much smoother across both PowerShell 5.1 and 7.
CyberSecWhiz99: I get that approach, but it's a bit tricky if you're dealing with sensitive permissions. For the scripts I'm working on, I need to ensure each user has to authenticate through our domain admin with MFA each time.
Reply to this answer
What about using device code flow? That way, you can open any browser you want. You can check out the Microsoft Learn docs for it.
ConcernedUser99: But wouldn't the security implications be similar to using certificates or secrets? Just wondering if there's real added protection.
Reply to this answer
Add your answer
Answers are reviewed before publication.
QuickMind22: Good point! I hadnโt thought of that. It might take a little extra time, but it's worth a shot.