r/PowerShell • • Sep 21 '26

Question Connect-MgGraph Authentication does not have an implementation

EDIT for resolution: as the comments said, the various modules were incompatible being loaded into one script. The script has been split up for AD / email / EXO only functions loading only those modules.

Also found that SQLSERVER module Microsoft.Graph module have an incompatibility https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2566

Load SQLSERVER first then Microsoft.Graph


I've got a handful of user management scripts that connect to EXO and Entra to manage accounts / email etc. They should be sending emails about new account creations, manage distribution groups, send password expiring reminders etc.

They've all been working without issues for a while until last week.

They are all failing at Connect-MgGraph / Send-MgUserMail

Here's the error block from the script transcript. It's the same error for the applicable line where Connect-MgGraph is in each script:

Connect-MgGraph : Method 'RefreshCacheAsync' in type 
'Microsoft.Graph.PowerShell.Authentication.Core.TokenCache.InMemoryTokenCacheOptions' from assembly 
'Microsoft.Graph.Authentication.Core, Version=2.40.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have 
an implementation.
At C:\scripts\NewUsers\NewUserSetup_AD.ps1:220 char:1
+ Connect-MgGraph -NoWelcome -ClientId $ClientId -TenantId $TenantId -C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Connect-MgGraph], TypeLoadException
+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph
Connect-MgGraph : Method 'RefreshCacheAsync' in type
'Microsoft.Graph.PowerShell.Authentication.Core.TokenCache.InMemoryTokenCacheOptions' from
assembly 'Microsoft.Graph.Authentication.Core, Version=2.40.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' does not have an implementation.
At C:\scripts\NewUsers\NewUserSetup_AD.ps1:220 char:1
+ Connect-MgGraph -NoWelcome -ClientId $ClientId -TenantId $TenantId -C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Connect-MgGraph], TypeLoadException
+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph

Send-MgUserMail : Authentication needed. Please call Connect-MgGraph.
At C:\scripts\NewUsers\NewUserSetup_AD.ps1:222 char:1
+ Send-MgUserMail -UserId "notification@company.com" -BodyParameter $Emai ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Send-MgUserMail_Send], AuthenticationException
+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.SendMgUserMail_Send
Send-MgUserMail : Authentication needed. Please call Connect-MgGraph.
At C:\scripts\NewUsers\NewUserSetup_AD.ps1:222 char:1
+ Send-MgUserMail -UserId "notification@company.com" -BodyParameter $Emai ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Send-MgUserMail_Send], AuthenticationException
+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.SendMgUserMail_Send

Feeling a little stuck on this one, I haven't found much about that error message.

I've verified the app registrations, certificates, client/tenant IDs etc. are still valid. The service account isn't locked out / password expired etc.

If this is helpful here are the PS and Module versions:

PS C:\Windows\system32> $PSVersionTable
    
Name                           Value                                                                                                                                                                                                                                          
    ----                           -----                                                                                                                                                                                                                                          
    PSVersion                      5.1.17763.9245                                                                                                                                                                                                                                 
    PSEdition                      Desktop                                                                                                                                                                                                                                        
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                                                        
    BuildVersion                   10.0.17763.9245                                                                                                                                                                                                                                
    CLRVersion                     4.0.30319.42000                                                                                                                                                                                                                                
    WSManStackVersion              3.0                                                                                                                                                                                                                                            
    PSRemotingProtocolVersion      2.3                                                                                                                                                                                                                                            
    SerializationVersion           1.1.0.1                                                                                                                                                                                                                                        
 

PS C:\Windows\system32> Get-Module Microsoft.Graph* -ListAvailable  
    
Directory: C:\Program Files\WindowsPowerShell\Modules   
    
ModuleType	Version	Name
----------	-------	----
Manifest	2.40.0	Microsoft.Graph
Script	2.40.0	Microsoft.Graph.Applications
Script	2.40.0	Microsoft.Graph.Authentication
Script	2.40.0	Microsoft.Graph.BackupRestore
Script	2.40.0	Microsoft.Graph.Bookings
Script	2.40.0	Microsoft.Graph.Calendar
Script	2.40.0	Microsoft.Graph.ChangeNotifications
Script	2.40.0	Microsoft.Graph.CloudCommunications
Script	2.40.0	Microsoft.Graph.Compliance
Script	2.40.0	Microsoft.Graph.ConfigurationMan...
Script	2.40.0	Microsoft.Graph.CrossDeviceExper...
Script	2.40.0	Microsoft.Graph.DeviceManagement
Script	2.40.0	Microsoft.Graph.DeviceManagement...
Script	2.40.0	Microsoft.Graph.DeviceManagement...
Script	2.40.0	Microsoft.Graph.DeviceManagement...
Script	2.40.0	Microsoft.Graph.Devices.CloudPrint
Script	2.40.0	Microsoft.Graph.Devices.Corporat...
Script	2.40.0	Microsoft.Graph.Devices.ServiceA...
Script	2.40.0	Microsoft.Graph.DirectoryObjects
Script	2.40.0	Microsoft.Graph.Education
Script	2.40.0	Microsoft.Graph.Files
Script	2.40.0	Microsoft.Graph.Groups
Script	2.40.0	Microsoft.Graph.Identity.Directo...
Script	2.40.0	Microsoft.Graph.Identity.Governance
Script	2.40.0	Microsoft.Graph.Identity.Partner
Script	2.40.0	Microsoft.Graph.Identity.SignIns
Script	2.40.0	Microsoft.Graph.Mail
Script	2.40.0	Microsoft.Graph.Notes
Script	2.40.0	Microsoft.Graph.People
Script	2.40.0	Microsoft.Graph.PersonalContacts
Script	2.40.0	Microsoft.Graph.Planner
Script	2.40.0	Microsoft.Graph.Reports
Script	2.40.0	Microsoft.Graph.SchemaExtensions
Script	2.40.0	Microsoft.Graph.Search
Script	2.40.0	Microsoft.Graph.Security
Script	2.40.0	Microsoft.Graph.Sites
Script	2.40.0	Microsoft.Graph.Teams
Script	2.40.0	Microsoft.Graph.Users
Script	2.40.0	Microsoft.Graph.Users.Actions
Script	2.40.0	Microsoft.Graph.Users.Functions
10 Upvotes

16 comments sorted by

3

u/BlackV Sep 21 '26

Are you also loading exchange modules?

Current versions fight each other

Most talk I've seen people are using the older versions of the modules

(Graph and exchange, you are using the latest by the looks)

1

u/FerrousBueller Sep 21 '26

Yes its got Exchange modules being loaded as well.

I see others are mentioning rolling back, I'll give that a shot.

3

u/FearAndGonzo Sep 21 '26

I've found loading/connecting to exchange first, then graph, still works for me most the time. Opposite order and it all breaks. But also sometimes it still is angry and I just close the ps window and start all over. Very annoying that MS can't make their modules work together.

6

u/Ecrofirt Sep 21 '26

I remember reading someone on here a few weeks back saying that they could no longer use both modules in the same script after a recent update.

2

u/Sekers Sep 21 '26 edited Sep 21 '26

This. Here's the GH issue: https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/3576

When I need this combo, I've been sticking with Windows PowerShell (Desktop) 5.1 and Graph module version 2.35.1 (with the latest ExchangeOnlineManagement Module Version I tested being 3.10.0, but later may work).

4

u/Certain-Finger8661 Sep 21 '26

There's incompatibilities between Exchange Online Management and Microsoft Graph Modules.

https://office365itpros.com/2025/09/24/assembly-clash-microsoft-365-ps/

There's a module that works around this problem here: https://github.com/SamErde/DLLPickle

1

u/ZigfriedWolf Sep 21 '26

What happens if you try that command outside of the script? If you are able to connect, then as others have said, you are probably running into an issue where they various powershell modules are fighting each other.

I ran into a similar issue with some of my scripts, and I had to break them up so that only 1 admin powershell module was used per script.

1

u/FerrousBueller Sep 21 '26 edited Sep 21 '26

That's where I was at with testing, I can get each section of the script to run separately/manually, just never thought it would be modules conflicting with each other - I'll file that away for next time.

I'll try rolling back the module version as others mentioned but might wind up splitting it up like you've got.

1

u/FerrousBueller Sep 21 '26

Rolling back the version didn't work, same error message.

I'll work on splitting the scripts and see if that resolves it.

2

u/titlrequired Sep 21 '26

Roll back the graph module? (What fun that is)

2

u/BlackV Sep 21 '26

What's hard about the -requiredversion parameter

Version pinning is about the best solution to any of these problems

2

u/fatalicus Sep 21 '26

The issue with the Graph module isn't realy installing a given version, since that is done like you say.

The issue is getting rid of the currently installed graph module, so that it doesn't mess up when you try to install the new one.

It isn't without reason that Merill Fernando has made a Powershell Module dedicated to uninstalling Graph, Entra and Azure powershell modules: https://uninstall-graph.merill.net/

1

u/BlackV Sep 21 '26 edited Sep 21 '26

I have to say I'm a little filthy, I don't think I've cleaned up a graph folder ever, there is a billion versions in there

but it does not only apply to installing a module, it also applies to importing a module

2

u/commiecat Sep 21 '26

Looks like 2.40.0 was released a few days ago. If you don't get a solution here, post as an issue on GitHub.

As a backup, you could use the Graph API directly via Invoke-WebRequest or Invoke-RestMethod and not have the SDK/module dependency.

2

u/ZigfriedWolf Sep 21 '26

Yeah, if the commands are running separately, then you almost certainly hit the same issue I did. Each module is calling a different version of the “Microsoft.Identity.Client.dll”, so once one loads in, the others attempt to use the loaded version rather than the one they need to run properly.

Separating the various admin modules into separate scripts will work. My script has like 4 steps. The first stage creates the user in AD, then creates a json file with the user info that gets passed via parameter input, so I don’t have to enter the same information for each subsequent stage of the script.

Also, if you are making this switch anyway, might as well look at running PowerShell 7 instead of 5.1. Microsoft just announced they are ending support for the SDK modules on 5.1 by this time next year:

https://devblogs.microsoft.com/microsoft365dev/investing-in-a-more-reliable-microsoft-graph-powershell-experience/

1

u/purplemonkeymad Sep 21 '26

Try using the previous version:

Install-Module -requiredversion 2.39.0 Microsoft.Graph.Authentication,Microsoft.Graph.Mail
Import-module -requiredversion 2.39.0 Microsoft.Graph.Authentication,Microsoft.Graph.Mail