Jump to content

Recommended Posts

Posted

Hello, I need to connect to both ExchangeOnlineManagement and Graph at the start of a script

 

If I run this first:

Import-Module -Name ExchangeOnlineManagement
Connect-ExchangeOnline -ShowBanner:$False

 

It connects to ExchangeOnline, but the Graph connection errors:

Import-Module Microsoft.Graph.Authentication -force      
Connect-MgGraph -NoWelcome -ContextScope Process
 
Connect-MgGraph -NoWelcome -ContextScope Process
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | InteractiveBrowserCredential authentication failed: Method not found:
 
 
 
If I run them in the other order Graph connects but Connect-ExchangeOnline errors:
OperationStopped: Object reference not set to an instance of an object.
 
 
What can I do?
Thanks
Posted

Q. "what can I do?"

 

A. Realise that Microsoft have genuinely lost the plot and move to Google.

 

I've not been able to figure out a winning formula.  For me, for the versions I have installed that load in the particular order that they do, on my machine, my scripts that do this work (mostly).  Two out of three colleagues have not managed to install the modules so that those scripts work, but  the other one has. It might genuinely be some days the modules available don't collide, and on other days, they can't both be loaded in the same session. 

Here's an article about it, probably written by actual humans from June this year: New PowerShell Releases Bring Both Grief and Joy

Posted

Is it running in PowerShell 5.x or 7.x?

 

If the latter, try using import-module 'exchangeonlinemanagement' -force -usewindowspowershell

Posted

that doesn't work. same error.

 

I dont mind splitting my script into 2 parts - connecting to graph, then disconnect and connect to EOL, but to disconnect the session seems to require closing/opening PS7, can anyone advise a command that will completly kill a connected graph session and another to kill a connected EOL session?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...