Konflikte zwischen PnP.PowerShell und Microsoft.Graph.Authentication Modul lösen

Nutzt jemand die beiden PowerShell Module PnP.PowerShell und Microsoft.Graph.Authentication in Scripts können Konflikte auftreten.

Aktuell sind es zwei bekannte und oft diskutierte Konflikte. Es liegt an veralteten DLL-Versionen im PnP.PowerShell Modul. Und nein, die Reihenfolge wie die Module geladen werden spielt in meinen Fällen keine Rolle. In meinen Fällen lade ich oftmals das PnP.PowerShell Modul gar nicht (nur das Modul Microsoft.Graph.Authentication).

Konflikt 1

Fehler “Microsoft.Graph.Core, Version=1.25.1.0” > Ursache und Lösung hatte ich im Februar beschrieben, siehe zudem die GitHub Diskussion.

Konflikt 2

Fehler „Could not load type ‚Microsoft.Identity.Client.BaseAbstractApplicationBuilder`1‘ from assembly ‚Microsoft.Identity.Client, Version=4.50.0.0“

PowerShell

Ähnlich zu Konflikt 1, es ladet aus dem PnP.PowerShell Modul eine veraltete Datei. Praktisch gesehen sollte Connect-MgGraph die Datei aus dem eigenen Modul nutzen.

[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location | Sort-Object -Property FullName | Select-Object -Property FullName, Location | where FullName -like "Microsoft.Identity.Client,*"
PowerShell

Überprüfung der Datei Microsoft.Identity.Client.dll im PnP.PowerShell Modul bestätigt die alte Version.

Veraltete Microsoft.Identity.Client.dll
Veraltete Microsoft.Identity.Client.dll

In GitHub wird das Problem beschrieben. Als Lösung erwähnt jemand die alte DLL im PnP.PowerShell Modul mit der aus Microsoft.Graph.Authentication zu ersetzen. Wurde die Datei ersetzt funktioniert Connect-MgGraph wieder. Löschen der Datei ist bei diesem Konflikt nicht ratsam. PnP.PowerShell benötigt die Datei.

Ich erstellte für beide Konflikte das PowerShell Script Resolve-TAPnPPowerShellConflicts. Das Script führt die erwähnten Lösungen für beide Konflikte aus. Beachte die Informationen im Script und meiner Dokumentation.

  • Für Konflikt 1, es löscht die Datei Microsoft.Graph.Core.dll aus dem PnP.PowerShell Directory. Connect-MgGraph ladet danach die korrekte DLL.
  • Für Konflikt 2, es überschreibt Microsoft.Identity.Client.dll im PnP.PowerShell Directory mit der Version aus Microsoft.Graph.Authentication. Connect-MgGraph kann danach die Verbindung ohne Fehler herstellen.
Microsoft.Identity.Client.dll wurde ersetzt
Microsoft.Identity.Client.dll wurde ersetzt

Beachte, nach einem Update des PnP.PowerShell Moduls ist die Ausführung erneut erforderlich.
Sollten durch die zwei Änderungen unerwartete Probleme mit PnP.PowerShell auftreten lässt es sich einfach lösen: Update-Module PnP.PowerShell -Force
Ein Update überschreibt alles was sich im aktuellen PnP.PowerShell Directory befindet.

Share this post:

About the Author

Tobias Asböck

Tobias Asböck

Tobias is a Senior System Engineer with more than 10 years of professional experience with Microsoft 365 products such as SharePoint Online, OneDrive for Business, Teams Collaboration, Entra ID, Information Protection, Universal Print, and Microsoft 365 Licensing. He also has 15+ years of experience planning, administering, and operating SharePoint Server environments. In his spare time, Tobias is busy with updates in the Microsoft 365 world or on the road with his road bike and other sports activities. If you have additional questions, please contact me via LinkedIn or support@topedia.com.

No comments yet