r/PowerShell • u/FerrousBueller • 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_SendFeeling 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
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)
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.
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.
2
u/titlrequired Sep 21 '26
Roll back the graph module? (What fun that is)
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-WebRequestorInvoke-RestMethodand 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: