PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.7k stars 490 forks source link

Conflict between Microsoft.Graph and PnP.PowerShell Modules in PowerShell Extension #5069

Open IoannisGianko opened 4 hours ago

IoannisGianko commented 4 hours ago

Prerequisites

Summary

I'm encountering an issue when using the Microsoft.Graph PowerShell module in combination with the PnP.PowerShell module while connecting via a certificate. The issue only occurs within the PowerShell Extension terminal in VSCode.

Expected Behavior: The command should execute successfully without any errors.

Actual Behavior: After connecting, any attempt to run a MgGraph command results in the following error: Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly 'Microsoft.Graph.Core, Version=1.25.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Notes:

Is there a known incompatibility between these two modules in the PowerShell Extension, or any workarounds besides downgrading the PnP.PowerShell module?

PowerShell Version

PS C:\Windows\System32> $psversionTable; $Host

Name                           Value
----                           -----
PSVersion                      7.4.5
PSEdition                      Core
GitCommitId                    7.4.5
OS                             Microsoft Windows 10.0.27729
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name             : ConsoleHost
Version          : 7.4.5
InstanceId       : e369b882-204a-431a-831e-136dd13cafce
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-GB
CurrentUICulture : en-GB
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

PS C:\Windows\System32> code --version
1.94.2
384ff7382de624fb94dbaf6da11977bba1ecd427
x64

Extension Version

PS C:\Windows\System32> code --list-extensions --show-versions | Select-String powershell

ms-vscode.←[7mpowershell←[0m@2024.2.2

Steps to Reproduce

  1. Install the Microsoft.Graph PowerShell module.
  2. Install the PnP.PowerShell module (any version newer than v2.2.0).
  3. Open the PowerShell Extension terminal in VSCode.
  4. Run the following command to connect to Microsoft Graph: Connect-MgGraph -ClientId $clientID -TenantId $tenantID -CertificateThumbprint $thumbPrint
  5. After connecting, attempt to run any MgGraph command. Get-MgOrganization

Visuals

mggraphnotworkingwithpnp18

Logs

No response

similar-issues-ai[bot] commented 4 hours ago

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.