-
Notifications
You must be signed in to change notification settings - Fork 513
Method not found with Connect-ExchangeOnline #5206
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
Comments
Please use PowerShell 7, or ensure that ExchangeOnlineManagement is the first module you load (disable anything in your profile). This is an assembly loading problem with the module itself, there's nothing we can do to fix this. |
Again, strongly recommend using PowerShell 7 in the PowerShell Extension terminal to avoid this problem, is there a strong reason why you aren't? This happens because the Microsoft.Identity.Client you have loaded (provided by exchange or something else) is not the version that your ExchangeOnlineManagement expects, and is missing a method it's looking for. Try running this to find where that DLL is loading from after you get this error: [System.AppDomain]::CurrentDomain.GetAssemblies() | where fullname -like 'Microsoft.Identity.Client*' |% location |
Unfortunately we have some internally created scripts/modules that need to be updated for PS7. It looks like it's getting extra copies from dbatools.library and Microsoft.Graph.Authentication, but those modules aren't loaded: When I fired up procmon and tested with powershell.exe directly, it only looks for that file under the module directory: However, when importing the module from the VSCode Integrated Terminal, it's looking in the rest of the module directories for that file. I did just find something interesting though; if instead of just doing import-module exchangeonlinemanagement I instead give it the full path of the ExchangeOnlineManagement.psd1 file, it doesn't go looking elsewhere for that file, and the module behaves as expected. |
The vscode extension may dynamically load modules based on your intellisense, so if loading exchangeonlinemanagement is not the first thing you do, and I mean very first, then you may have this problem. PowerShell 7 avoids this with ALCs, and there's no reason you can't use PowerSHell 7 to author PowerShell 5.1 scripts, so I again would strongly recommend you install PowerShell 7 on your dev box to write the scripts, and then you can test them in PowerShell 5.1 as well if needed, as PowerShell 5.1 is only best-effort supported. Hope that helps! |
Prerequisites
Summary
ExchangeOnlineManagement versions higher than 3.7.1 throw an error when running Connect-ExchangeOnline in VSCode:
In a standalone PowerShell instance it works as expected.
I know this is often due to extension conflicts, but I've tried this without my $profile, and with ExchangeOnlineManagement the first module loaded
PowerShell Version
Visual Studio Code Version
Extension Version
Steps to Reproduce
connect-exchangeonline
Visuals
Logs
PowerShell Trace LSP.log
PowerShell.log
StartEditorServices-24980.log
The text was updated successfully, but these errors were encountered: