Method not found 'Void Microsoft.Graph.TokenCredentialAuthProvider'

Brass Contributor


I try to run a runbook in Hybrid Worker to collect info from Azure Registered Apps. For that activity I connect to MS Graph with certificate and execute Get-MgApplication cmdlet. However, I see "Welcome to Microsoft Graph!" response and then:

Get-MgApplication : Method not found: 'Void Microsoft.Graph.TokenCredentialAuthProvider..ctor(Azure.Core.TokenCredential, System.Collections.Generic.IEnumerable`1<System.String>)'. At line:24 char:1 + $SApps = Get-MgApplication -all + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-MgApplication_List], MissingMethodException + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgApplication_List


My current version module is 2.0.0-preview5, but I also tried other versions and got different results (but never successful). All cmdlets, including connecting via certificate, can be executed successfully locally and within Azure runbook.
I run out of ideas. Any ideas?

6 Replies



I'd only expect to see that kind of error under the following conditions:


  • A bug in the module;
  • You have multiple versions concurrently installed and the wrong one is being called (likely one featuring an older version of Azure.Core.dll.)


I'm inclined to think it'll be the second case, in which case you can run the following script to remove all currently-installed versions (this is based on Windows PowerShell, not PowerShell) and re-install them (see the note in the comments about scope):


I don't use beta/pre-release versions and I am aware they sometimes need manual eviction. I haven't catered to this scenario in the script below.



    Local administration rights are required for the "-Scope AllUsers" option to work. Otherwise, remove that option from the commandlets to do a per user refresh.
    $Scope = "AllUsers";

    # Enumerate the currently-installed modules from the AllUsers scope.
    $Modules = (Get-Module -ListAvailable -Name "Microsoft.Graph.*" -ErrorAction:Stop).Name | Select-Object -Unique;

    # Output the list to the pipeline as a "just in case".
    Write-Warning -Message "Modules detected:";

    # Now, chuck 'em all in the bin.
    $Modules |
        ForEach-Object {
            Uninstall-Module -Name $_ -AllVersions -Force -ErrorAction:Stop;

    # The authentication module is a prerequisite for all the other Graph modules (which throw a warning on installation if this one isn't already present), hence breaking it out to be first to be re-installed.
    Install-Module -Name "Microsoft.Graph.Authentication" -Scope $Scope -Force -ErrorAction:Stop;

    # Re-install the rest, excluding the authentication module from above.
    $Modules |
        ForEach-Object {
            if ($_ -ne "Microsoft.Graph.Authentication")
                Install-Module -Name $_ -Scope $Scope -Force -ErrorAction:Stop;





The cmdlet works fine for me on 1.23.0, using CBA. I'm with Lain on this, avoid using preview versions, the Graph module is buggy enough as it is...

@LainRobertson @VasilMichev 
Alright. I wiped out module repository and reinstalled all modules (MSGraph 1.23), including Azure.Core.dll which is a part of Az.Accounts (2.12.1). That didn't help and I started getting "Connect-MgGraph : <ThumbprintId> certificate was not found or has expired".
Then I tried to import a certificate using Runbook into CurrentUser with "Import-PfxCertificate

-FilePath "localPath" -CertStoreLocation Cert:\CurrentUser\My\", but I got again: "Connect-MgGraph : <certName> certificate was not found or has expired."
I tried to use the guide and specify the cert path: "$Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint", but this time I got the same error, but instead of basic <certName>, I got full details of my certificate with ending message "certificate was not found or has expired." which is kind of ridiculous, because the certificate is displayed.

Locally and from Runbook all working well. I just run out of ideas what else could be wrong.





I'd expect this to be about the placement of the certificate - as per the other thread.


As I mentioned there, I don't use the hybrid runbook server meaning I can't perform a like-for-like test, but I'm not having any issues with certificate-based authentication under version 1.23.0.


It tested successfully for me - using an Azure servicePrincipal - both from the certificate store as well as from file, but keep in mind (as per the link in the other thread) that the hybrid runbook documentation specifies a more unique location than the CurrentUser\My or LocalMachine\My stores, so it's got some of its own peculiarities to navigate.


I'd suggest running your own test outside of the runbook scenario as a cross-reference. If that works - and I'd wager it will - then at least that'll be fairly solid evidence (as much as anything ever is) it's not the Graph PowerShell modules.




Hey, still i am getting the same error . Please can you help@Alex_Rechs 

Eventually I installed Microsoft Graph version 1.24.0 on Hybrid Worker machine
I remember I installed that certificate under system account and Hybrid Worker account, but I don't recall what worked and at this point I'm afraid to touch it :)
The way I connect to Graph is:
Connect-MgGraph -CertificateThumbprint "<certThumbprint>" -ClientID "<clientID>" -TenantID "<tenantID>"
Select-MgProfile -name Beta

I hope that helps.