Skip to content

[BUG] Microsoft.Graph and PnP.PowerShell conflict (Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider') #3920

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

Closed
nicole-ge opened this issue Apr 26, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@nicole-ge
Copy link

nicole-ge commented Apr 26, 2024

Describe the bug
When using the Microsoft.Graph and PnP.PowerShell module in the same script

fails with the following exception:
Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly 'Microsoft.Graph.Core, Version=1.25.1.0, Culture=neutral, PublicKeyToken=315'.

The error occurs if the script is executed locally as well as an Azure Automation runbook.

Using module 2.4.0 | PnP.PowerShell in Azure Automation

@nicole-ge nicole-ge added the bug Something isn't working label Apr 26, 2024
@nicole-ge
Copy link
Author

Hello @gautamdsheth

Can you help to fix this issue?

My bug seemed to similar to
Bug #2285

@gautamdsheth
Copy link
Collaborator

Closing as duplicate of #3637 .

We are tracking that via the above linked issue, no updates as yet for that unfortunately.

@gautamdsheth gautamdsheth closed this as not planned Won't fix, can't repro, duplicate, stale Apr 27, 2024
@nicole-ge
Copy link
Author

Hi @gautamdsheth

Thank you for your answer. This bug seems to concern a lot of people and we have no workaround for it. How can I help to solve this bug? Please let me know I need to work with pnp and graph in one powershell script within one runbook

@RobIreland-OastHouseLtd
Copy link

RobIreland-OastHouseLtd commented Apr 30, 2024

Seeing the same issue, my DEV VM is Windows 11 and has the following installed

PowerShell Version: 7.4.2
PnP PowerShell Version: 2.4.0
Microsoft.Graph Version: 2.18.0
Microsoft.Graph.Beta Version: 2.18.0
Microsoft.Identity.Client: 4.53.0

The error happens in the following line of code

$eid = get-mggroup -consistencylevel eventual -search $groupSearchTerm …
     | Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly      
     | 'Microsoft.Graph.Core, Version=1.25.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Consistently happens when I'm running the script via VS Code Terminal Window (Powershell 7.4.2 process) or from my Terminal Window (PowerShell 7.4.2)

@scm7ak
Copy link

scm7ak commented Jul 8, 2024

if you run the Graph stuff in a separate runspace (in my case a job), then you can circumvent the issue.

It's not a fix, but a workaround.

I hope there is a resolution soon.

@nicole-ge
Copy link
Author

Seeing the same issue, my DEV VM is Windows 11 and has the following installed

PowerShell Version: 7.4.2
PnP PowerShell Version: 2.4.0
Microsoft.Graph Version: 2.18.0
Microsoft.Graph.Beta Version: 2.18.0
Microsoft.Identity.Client: 4.53.0

The error happens in the following line of code

$eid = get-mggroup -consistencylevel eventual -search $groupSearchTerm …
     | Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly      
     | 'Microsoft.Graph.Core, Version=1.25.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Consistently happens when I'm running the script via VS Code Terminal Window (Powershell 7.4.2 process) or from my Terminal Window (PowerShell 7.4.2)

I have the same issue. Have someone a workaround?

@khha
Copy link

khha commented Nov 18, 2024

I have the same issue. Im using pnp version 2.12.0 and get the error:

Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly 'Microsoft.Graph.Core, Version=1.25.1.0,
      | Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

@carl0ski
Copy link

carl0ski commented Dec 4, 2024

Seeing the same issue, my DEV VM is Windows 11 and has the following installed
PowerShell Version: 7.4.2
PnP PowerShell Version: 2.4.0
Microsoft.Graph Version: 2.18.0
Microsoft.Graph.Beta Version: 2.18.0
Microsoft.Identity.Client: 4.53.0
The error happens in the following line of code

$eid = get-mggroup -consistencylevel eventual -search $groupSearchTerm …
     | Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly      
     | 'Microsoft.Graph.Core, Version=1.25.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Consistently happens when I'm running the script via VS Code Terminal Window (Powershell 7.4.2 process) or from my Terminal Window (PowerShell 7.4.2)

I have the same issue. Have someone a workaround?

#3637

They had 1 Delete the 125 file Microsoft.Graph.Core.dll from Modules PNP.Powershell Core Folder
but some modules like Get-PnPSiteTemplate have a hard coded dependency to 1.25
which i guess is why it has not been fixed for so long overall

Another was to do all the MG work first to force it to load the native Microsoft.Graph.Core.dll first
but that too seems to fail to allow MG run after any PNP occurs
PNP unloads the real Microsoft.Graph.Core.dll and breaks all MG as soon as PNP commands are run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants