Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run Microsoft Graph & ExchangeOnlineManagement commands together in PowerShell #2850

Closed
blackadi opened this issue Jul 16, 2024 · 12 comments
Labels
no-recent-activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close

Comments

@blackadi
Copy link

Describe the bug

When running Graph commands and ExchangeOnlineManagement commands in a single script it throws an error.

why these 2 modules don’t work together?

Expected behavior

Understand why MS Graph and ExchangeOnlineManagement modules don’t work together?

How to reproduce

running Graph commands and ExchangeOnlineManagement commands in a single script

SDK Version

2.20

Latest version known to work for scenario above?

No response

Known Workarounds

script run in PowerShell 7 but not in in PowerShell 5.

We need PowerShell 5 support since we are using Azure Automation Runbooks which currently support PowerShell 5 runbok only.

Debug output

Click to expand log ```

System.Management.Automation.CommandNotFoundException: The 'Connect-MgGraph' command was found in the module 'Microsoft.Graph.Authentication', but the module could not be loaded. For more information, run 'Import-Module Microsoft.Graph.Authentication'. ---> System.Management.Automation.CmdletInvocationException: Could not load file or assembly 'Azure.Core, Version=1.35.0.0, Culture=neutral, PublicKeyToken=' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Azure.Core, Version=1.35.0.0, Culture=neutral, PublicKeyToken=' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.5.0\netFramework\Azure.Core.dll' or one of its dependencies. The system cannot find the file specified.

</details>


### Configuration

_No response_

### Other information

_No response_
@blackadi blackadi added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jul 16, 2024
@titlerequired
Copy link

In what order do you authenticate in the runbook?

I think I had a similar issue previously but recently this has been working ok for me recently.

@blackadi
Copy link
Author

blackadi commented Jul 16, 2024

@titlerequired first connecting to MSGraph via this cmdlet Connect-MgGraph -AccessToken ($oAuthReq.access_token | ConvertTo-SecureString -AsPlainText -Force) -NoWelcome then Import-Module ExchangeOnlineManagement

@titlerequired
Copy link

You still need to use Connect-ExchangeOnline

@alexandair
Copy link
Contributor

@blackadi

You can use PowerShell 7.2 in Azure Automation.
image

@yllekz
Copy link

yllekz commented Jul 18, 2024

Same issue here (and yes I'm using Connect-ExchangeOnline). Latest version (I jumped to 2.20.0 from 2.16.0) appears to completely break coexistence between these two and should be fixed immediately. I've had to roll back due to this bug.

@ildjarnisdead
Copy link

ildjarnisdead commented Jul 19, 2024

Workaround: First Connect-MgGraph and then Connect-ExchangeOnline works.
The other way round does not work.

The actual error occurs while loading Microsoft.Graph.Authentication:
Import-Module : Could not load file or assembly 'file:///C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.5.1\netFramework\Azure.Core.dll' or one of its dependencies. The system cannot find the file specified.

@timayabi2020 timayabi2020 added Status: Needs Investigation and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Jul 25, 2024
@timayabi2020
Copy link
Contributor

Hello guys. Please update to the latest Microsoft.Graph PowerShell SDK and let us know if you are still experiencing the same issue. A similar issue has been logged here #2803

@timayabi2020 timayabi2020 added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Status: Needs Investigation type:bug A broken experience labels Jul 29, 2024
@secretworkpersona
Copy link

Latest version (2.21.0) does not resolve the issue for me.

ModuleError

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@yllekz
Copy link

yllekz commented Aug 3, 2024

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

bump

@k3wio
Copy link

k3wio commented Aug 7, 2024

@timayabi2020 This issue is still active and present in current versions. Would you like yet another issue opened, or can we have this one reopened as it is not, in fact, completed.

@syne0
Copy link

syne0 commented Aug 8, 2024

I want to advise that this issue is still occurring for me as well, but not always consistently. It's hard to pin down specific triggers, but I usually end up reinstalling graph and eom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-recent-activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close
Projects
None yet
Development

No branches or pull requests

9 participants