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

Unable to connect to Exchange Online #4385

Closed
5 of 6 tasks
foss4ever opened this issue Jan 19, 2023 · 15 comments
Closed
5 of 6 tasks

Unable to connect to Exchange Online #4385

foss4ever opened this issue Jan 19, 2023 · 15 comments
Assignees
Labels
Area-Extension Terminal Issue-Bug A bug to squash. Resolution-External Will close automatically.

Comments

@foss4ever
Copy link

foss4ever commented Jan 19, 2023

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

I can't connect to Exchange Online from VS Code terminal.
Running command "connect-exchangeonline" I get the following error:

OperationStopped: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.44.0.0, Culture=neutral, PublicKeyToken=03ae'.

The issue does not reproduce in standalone PowerShell terminal.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.3.1
PSEdition                      Core
GitCommitId                    7.3.1
OS                             Darwin 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct  9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

Version: 1.74.3
Commit: 97dec172d3256f8ca4bfb2143f3f76b503ca0534
Date: 2023-01-09T17:07:18.579Z (1 wk ago)
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin x64 22.1.0
Sandboxed: No

Extension Version

The term 'code' is not recognized as a name of a cmdlet, function, script file, or executable program.

Steps to Reproduce

  1. Start terminal
  2. Run: sudo pwsh
  3. Run: Install-Module -Name ExchangeOnlineManagement
  4. Start VS Code
  5. Run: import-module ExchangeOnlineManagement
  6. Run: connect-exchangeOnline

Visuals

No response

Logs

No response

@foss4ever foss4ever added the Issue-Bug A bug to squash. label Jan 19, 2023
@ghost ghost added the Needs: Triage Maintainer attention needed! label Jan 19, 2023
@jerome-dl
Copy link

jerome-dl commented Jan 27, 2023

I have the same issue since I updated ExchangeOnlineManagement module.
I also installed the requested version for Microsoft.Identity.Client module, and uninstalled other versions.

Get-InstalledModule

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
3.1.0                ExchangeOnlineManagement            PSGallery            This is a General Availability (GA) release of the Exchange Online Powershell V3 module. Exchange Onl…
7.8.4                ImportExcel                         PSGallery            PowerShell module to import/export Excel spreadsheets, without Excel.…
4.44.0               Microsoft.Identity.Client           PSGallery            This package contains the binaries of the Microsoft Authentication Library for .NET (MSAL.NET).…
1.12.0               PnP.PowerShell                      PSGallery            Microsoft 365 Patterns and Practices PowerShell Cmdlets

@andyleejordan
Copy link
Member

Can you confirm that you can run the module as expected in a normal PowerShell terminal, that is, not in VS Code?

@andyleejordan andyleejordan added Needs: Author Feedback Please give us the requested feedback! and removed Needs: Triage Maintainer attention needed! labels Jan 31, 2023
@foss4ever
Copy link
Author

foss4ever commented Feb 1, 2023

Yes, here you go:

image

@ghost ghost added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Author Feedback Please give us the requested feedback! labels Feb 1, 2023
@ksl28
Copy link

ksl28 commented Feb 13, 2023

I can confirm, that im seeing the same issue.
VScode: 1.74.2 (User setup)
Pwsh: 7.3.2

@jerome-dl
Copy link

I need to share that the issue was solved, on my side, thanks to this finding from pttbr !
It occurs when using ExchangeOnlineManagement and PnP.PowerShell modules together.

@andyleejordan
Copy link
Member

Thank you @jerome-dl! That's...super interesting because the flip side of this issue is the same weird "it just doesn't work" with PnP.PowerShell #3510

@foss4ever
Copy link
Author

I now have the same error coming up when attempting to connect to msonline in powershell terminal.

billede

@andyleejordan
Copy link
Member

I have you tried the workaround posted above?

@foss4ever
Copy link
Author

I have you tried the workaround posted above?

What is the workaround exactly? It's not clear to me from the linked issue which mentions PnP.PowerSell, but I haven't ever used that module, so how does that enter the picture? Getting a bit confused here :)

@andyleejordan
Copy link
Member

A whole bunch of modules, like PnP.PowerShell and Exchange Online, rely on different (and conflicting) versions of some of the identity assemblies. The simplest workaround is to avoid loading any other module before trying Exchange Online, and that will likely work, but you need to check your profile or scripts you might be loading before using the module. Otherwise some people have had success altering the Exchange Online module manifest.

@foss4ever
Copy link
Author

foss4ever commented Mar 3, 2023

A whole bunch of modules, like PnP.PowerShell and Exchange Online, rely on different (and conflicting) versions of some of the identity assemblies. The simplest workaround is to avoid loading any other module before trying Exchange Online, and that will likely work, but you need to check your profile or scripts you might be loading before using the module. Otherwise some people have had success altering the Exchange Online module manifest.

That does in fact seem to work for the ExchangeOnlineManagement module, but not for the MSOnline module:

billede

I'm afraid the thing you mention about altering manifests is a little bit beyond my skills, as I am really just a sysadmin trying to get all the Office 365 related modules working in VSCode on MacOS, so that I no longer have to deal with this in my Windows VM ^_^

@andyleejordan
Copy link
Member

Oh, @foss4ever, your screenshot actually shows that you're not in the Extension Terminal, so your issue is directly with MSOnline. You're in a regular pwsh terminal (that happens to be in Code's Integrated terminal). Can you please open an issue with them?

This repository is specifically for issues with the PowerShell Extension, and so specifically the "PowerShell Extension" terminal, the one selected in this screenshot (it'll also have a "PowerShell Extension v2023.2.1" banner when it starts up):

Screenshot 2023-03-03 at 10 15 59 AM

If your issue occurs in one that just says "pwsh" not "PowerShell Extension" then it's not related to the code in this repo. I can still try to direct you to help, but it's not something I can solve.

In the article I linked (best thing I could find for "MSOnline") I would note that it says:

Please note that we will begin to deprecate this module when the functionality of this module is available in the newer Azure Active Directory PowerShell for Graph module. We advise customers who are creating new PowerShell scripts to use the newer module instead of this module.

So it's possible that module isn't even supported any more. Sorry! I hope you find a solution.

@andyleejordan andyleejordan added the Resolution-External Will close automatically. label Mar 9, 2023
@ghost ghost closed this as completed Mar 9, 2023
@ghost
Copy link

ghost commented Mar 9, 2023

This issue has been marked as external. It has been automatically closed for housekeeping purposes.

Debug/Terminal Reliability automation moved this from In progress to Done Mar 9, 2023
@foss4ever
Copy link
Author

@andschwa

I'm sorry for not getting back on this issue sooner, and for hassling you about a deprecated msonline module, but I do in fact get that very same error when attempting to connect-azuread in the PowerShell Extension terminal within VSCode:

image

Do I need to open a new issue for that?

@andyleejordan
Copy link
Member

@foss4ever not sure what's going on there, a lot that could be wrong. System.Windows.Forms is in .NET Core now, but I think maybe still Windows-only...it also looks like it could be a dependency conflict between it and another module. Please do open another issue!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Extension Terminal Issue-Bug A bug to squash. Resolution-External Will close automatically.
Projects
No open projects
Development

No branches or pull requests

4 participants