[BUG] Assembly Conflicts with Microsoft.Graph Module · Issue #3637 · pnp/powershell · GitHub
Skip to content

[BUG] Assembly Conflicts with Microsoft.Graph Module #3637

Closed

Description

@cprovpo

Reporting an Issue or Missing Feature

Running Microsoft.Graph cmdlets, such as Connect-MgGraph and Get-MgApplication, produce an assembly conflict error if run after PnP.PowerShell assemblies have already been loaded.

Expected behavior

According to release notes for PnP.PowerShell 2.3.0, assembly conflicts have been resolved. With this being true, I was hopeful I could develop a script that used cmdlets from both PnP.PowerShell and Microsoft.Graph. In my scenario, this doesn't appear to be the case.

Actual behavior

Results from trying to run Connect-MgGraph and Get-MgApplication after PnP had already been loaded:
image

Output of assemblies loaded in the session. The two assemblies called out in the MgGraph exception are sourced from the PnP.PowerShell Module
image

Steps to reproduce behavior

Import-Module PnP.PowerShell
Connect-PnPOnline -Url $url -Interactive
Disconnect-PnPOnline
Import-Module Microsoft.Graph
Connect-MgGraph
Connect-MgGraph -TenantId $TenantId -ClientSecretCredential $ClientSecretCredential
Get-MgApplication
Disconnect-MgGraph

What is the version of the Cmdlet module you are running?

PnP.Powershell - 2.3.3 Nightly Build
Microsoft.Graph.Authentication - 2.9.0
Microsoft.Graph.Applications - 2.9.0

Which operating system/environment are you running PnP PowerShell on?

  • [x ] Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify

Activity

  1. JNichNP commented on Dec 20, 2023

    @JNichNP

    I fixed this by grabbing the Microsoft.Graph.Core.dll from Microsoft.Graph.Authentication and dropping it right into C:\Program Files\PowerShell\Modules\PnP.PowerShell\2.3.8\Core

    Not the best, nor the most elegant solution, but it worked.

  2. Jaffa666 commented on Dec 21, 2023

    @Jaffa666

    I fixed this by grabbing the Microsoft.Graph.Core.dll from Microsoft.Graph.Authentication and dropping it right into C:\Program Files\PowerShell\Modules\PnP.PowerShell\2.3.8\Core

    Not the best, nor the most elegant solution, but it worked.

    Also grab the Microsoft.Identity.Client.dll from Microsoft.Graph.Authentication and replace the PnP version. This resolved Connect-MGGRAPH error trying to use the older dll files from the PnP module if it was called first.

  3. cprovpo commented on Dec 26, 2023

    @cprovpo
    Author

    Thanks for the suggested workarounds - I'll be sure to test those. I am concerned about the lengthy regression testing that might be required by replacing these, as I'm not sure if the replaced DLLs will cause issues with the rest of my code.

  4. cprovpo commented on Jan 12, 2024

    @cprovpo
    Author

    As an update to my previous post, I have tried the DLL replacements as indicated above. While this resolves the authentication issue, calling other Graph cmdlets (such as Get-MgUser) reveals other assembly conflicts

    Get-MgUser_List: Method not found: 'Void Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[], Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'.

    Unfortunately, we are at a crossroads in getting utility out of both PnP.PowerShell and Microsoft.Graph.

  5. cprovpo commented on Jan 12, 2024

    @cprovpo
    Author

    One final update - I think I may have found a valuable workaround tool, and it's built in:

    Invoke-PnPGraphMethod

    I was just able to pull Users and Applications from Graph API without any assembly conflicts. I did not know this cmdlet exists, but it seems like an excellent workaround. A quick sample of a couple commands I ran

    $users = Invoke-PnPGraphMethod -Url "/users"
    $applications = Invoke-PnPGraphMethod -Url "/applications"
    

    Hopefully this helps someone else!

  6. fasteiner commented on Jan 18, 2024

    @fasteiner

    The issue persists with the new version of graph (2.12.0) and PNP 2.3.0, could you please fix this issue? otherwise people are forced to work with the old PNP version 1.12.0.

    Error Message when connecting to graph, after connecting to PNP:
    ERROR - Connect to Microsoft Graph failed.(TenantId: tttech365.onmicrosoft.com, AppId ****)
    ERROR -
    Connect-MgGraph:
    Line |
    135 | Connect-MgGraph -TenantId $AzureTenant -ClientId $AppId - …
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | ClientCertificateCredential authentication failed: Could not load type 'Microsoft.Identity.Client.BaseAbstractApplicationBuilder`1' from assembly 'Microsoft.Identity.Client, Version=4.50.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'.

  7. gkDoSt commented on Feb 8, 2024

    @gkDoSt

    Any updates on this?
    Im facing the same issue :/

  8. MichaMican commented on Feb 8, 2024

    @MichaMican

    Same issue here. Absolutely horrible bug tbh.
    This is currently a hard blocker for us as for security and regularoty reasons we may not tamper with module files of modules, hence we can't work with the workarround by @JNichNP

  9. HeKr09 commented on Feb 19, 2024

    @HeKr09

    Is there anything new? This is a really annoying bug.

  10. rvanandel-hcg commented on Feb 19, 2024

    @rvanandel-hcg

    Add me to the list of people who are experiencing this issue. Brand new server with the lastest versions of PNP and Graph modules. There's gotta be a way to fix this. Seems both Graph and PNP teams are blaming the other team rather than coming up with a solution.

  11. crnnr commented on Feb 21, 2024

    @crnnr

    Is there a timeline for this? Also facing this issue with workaround not feasible :///

  12. jdarre commented on Feb 23, 2024

    @jdarre

    Any update here? As of now, we have to run a single server with PnP.Powershell 2.3.0 and version 1.28 of the Mg-Module.

  13. Legitage commented on Feb 25, 2024

    @Legitage

    Our automation scripts are also failing with the same error and for the same reason. Another short-term (not ideal) workaround for using PnP 2.3 is to uninstall the MS Graph module and/or install Microsoft.Graph 2.8.

    This DLL version conflict needs to be resolved in way that it doesn't keep happening every few updates.

  14. cyrilchotard commented on Mar 4, 2024

    @cyrilchotard

    Same issue for me in Azure Automation with PnP.PowerShell 2.4.0 and Microsoft.Graph 2.15.0

  15. 44 remaining items

  16. simonsabin commented on Feb 14, 2025

    @simonsabin

    Found this to be an awesome solution as it occurs for me in VsCode and the issue is that the PS extension is loading the modules and resulting in the wrong assemblies being loaded.

    Essentially you set VSCode to run the file in a new terminal, rather than use the one the extension lives in.

    I changed my launch to contain this. The createTemporaryIntegratedConsole being the key entry.

      {
                "name": "PowerShell: Launch Current File",
                "type": "PowerShell",
                "request": "launch",
                "script": "${file}",
                "args": [],
                "createTemporaryIntegratedConsole": true
            }
    
  17. HeKr09 commented on May 5, 2025

    @HeKr09

    Now that there is v3 available: Does anyone knows whether the issue persists?

  18. gautamdsheth commented on May 23, 2025

    @gautamdsheth
    Collaborator

    Hello all, thank you for the patience. Took quite a while , but we finally removed the Graph dependency which was causing the conflict. Would encourage you to update to the latest nightly builds (3.1.36-nightly or later ) and let us know.

  19. kpinel commented on May 25, 2025

    @kpinel

    I'm using 3.1.0 and initial checks show that it's working regardless of the order of connection.
    Updating my test environment and will monitor closely

  20. Borgquite commented on May 27, 2025

    @Borgquite

    @gautamdsheth Since Microsoft.Graph.Core.dll is no longer included in the package for 3.1.34-nightly+, unlike 3.1.33-nightly, and removing this file solves at least one of these errors, I'd say it's looking promising!

    From my initial testing I seem to be able to use PnP.PowerShell nightly alongside Graph without deleting files. Thank you!

  21. rvanherk commented on Jul 24, 2025

    @rvanherk

    We tested with the nightly build 3.1.98 and indeed it now seems to work! Hopefully this fix will be committed soon to a new Build

  22. erickvtorres commented on Sep 22, 2025

    @erickvtorres

    I fixed this by grabbing the Microsoft.Graph.Core.dll from Microsoft.Graph.Authentication and dropping it right into C:\Program Files\PowerShell\Modules\PnP.PowerShell\2.3.8\Core

    Not the best, nor the most elegant solution, but it worked.

    Working 👍🏻

  23. zaaj commented on Oct 20, 2025

    @zaaj

    With the nightly builds having a working fix for about 5 months now, what's the timeline looking like for a fixed version making it into a release?

    I see workaround about connect-mggraph before the PNP connection, but my uses are more often interactive at a Powershell prompt, so depending on the day's tasks, I might connect in one order vs another, and may have a number of variables stuffed with data I'm working on - leaving those behind to start a new session is a pain.

  24. RobIreland68 commented on Oct 20, 2025

    @RobIreland68
  25. gautamdsheth commented on Nov 8, 2025

    @gautamdsheth
    Collaborator

    @zaaj - sorry about the delay. We are currently blocked from a release due to certificate issues. We hope to have it out soon, preferably sometime this month itself .

  26. self-assigned this
    on Dec 14, 2025
  27. JakeyNZ commented on Feb 24, 2026

    @JakeyNZ

    I am also still having this issue in 3.1.0 Error "Get-MgUserMailFolder_List: Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly 'Microsoft.Graph.Core, Version=1.25.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'"

    Work around is to run Connect-MgGraph and then run a command. This will ensure you are using the right dll. Then you can run Connect-PnPOnline and use both libraries with no issue.

    FullName : Microsoft.Graph.Authentication, Version=2.25.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    Location : C:\Program Files\PowerShell\Modules\Microsoft.Graph.Authentication\2.25.0\Microsoft.Graph.Authentication.dll
    
    FullName : Microsoft.Graph.Core, Version=1.25.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    Location : C:\Program Files\PowerShell\Modules\PnP.PowerShell\3.1.0\Core\Microsoft.Graph.Core.dll
  28. FabienTschanz commented on Feb 27, 2026

    @FabienTschanz
    Contributor

    @gautamdsheth Sorry for the direct ping but is there any timeline for a new release of PnP.PowerShell that includes this fix? Appreciate your work on it.

  29. gautamdsheth commented on May 11, 2026

    @gautamdsheth
    Collaborator

    We just released a new version today after more than a year with this bug fix.
    Sorry and apologies for the delay and thanks for the patience , will close this issue now !
    Please do let us know if the issue persists with the 3.2.0 , from what i read, it was fixed in the nightly builds and the code related to this is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions