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?
3 Answers
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.
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.
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.
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.
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.
Good point! I hadn’t thought of that. It might take a little extra time, but it's worth a shot.
But wouldn't the security implications be similar to using certificates or secrets? Just wondering if there's real added protection.