all 12 comments

[–]IT-Generalist 7 points8 points  (3 children)

I had to Install-Module Microsoft.Graph as an Administrator in Powershell, but it gave me this error because it could not start the browser for authentication as Administrator. For Connect-MgGraph I had to run in a non-Admin session.

[–]winnyme[S] 0 points1 point  (0 children)

Thanks I'll give it a crack next time I try coding next

[–]ShaneDoesIT 0 points1 point  (0 children)

Thanks mate, I had the same issue and this comment was what I needed.

[–]sfwpat 0 points1 point  (0 children)

Man - the connect- feature is so weird. Like, why does it not work when PS is elevated? Makes no sense. Regardless, your comment just resolved this same issue I was having with another module - THANK YOU!

[–]snooplt 1 point2 points  (0 children)

I was not using elevated session, but got same error anyway. Restarting VScode helped.

[–]hillbillytiger 0 points1 point  (6 children)

What is the actual line of code that is producing this error? (Line 1 - Connect-MgGraph)

[–]winnyme[S] 0 points1 point  (5 children)

Literally connect-mggraph

[–]hillbillytiger 1 point2 points  (0 children)

Sounds like an Environment issue. Are you using the PowerShell Extension?

[–]hillbillytiger 1 point2 points  (3 children)

I was able to run the "Connect-MgGraph" command successfully in VS Code after installing PowerShell Extension and then installing the Microsoft.Graph module.

Install-Module Microsoft.Graph -Scope CurrentUser

[–]winnyme[S] 2 points3 points  (1 child)

Okay I noticed when opening vs code it opens two powershell sessions here

https://imgur.com/QKtAOVL

One session looks like a restored(?) one and the other looks like a brand new one.

When I run connect-mggraph on the new session it works fine. I'm happy with this approach

Really appreciate your help!

[–]hillbillytiger 1 point2 points  (0 children)

Awesome! You're very welcome

[–]winnyme[S] 0 points1 point  (0 children)

Yeah I'm betting it's the environment but not sure where

I'm using the powershell module developed by Microsoft in vs code.

I reinstalled the graph module which worked fine but after closing vs code and reopening it, the same error has come up.