Skip to content
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

Version 2.18.0 broken - Method not found: error #2703

Closed
marckean opened this issue Apr 25, 2024 · 13 comments
Closed

Version 2.18.0 broken - Method not found: error #2703

marckean opened this issue Apr 25, 2024 · 13 comments

Comments

@marckean
Copy link

Describe the bug

I am running this:

if (-not(Get-Module -ListAvailable -Name Microsoft.Graph.Groups)) {
Install-Module -Name Microsoft.Graph.Groups -Scope CurrentUser -AllowClobber -Force
Import-Module -Name Microsoft.Graph.Groups
}

Sign into the Microsoft Graph

$resource = "https://graph.microsoft.com"
$token = (Get-AzAccessToken -TenantId $tenantID -ResourceUrl $resource).Token

Create a SecureString from the token

$SecureToken = ConvertTo-SecureString $token -AsPlainText -Force

Use the SecureString token to connect

Connect-MgGraph -AccessToken $SecureToken

But I get this error:

Method not found: 'Void Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[], Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'.

Expected behavior

I should get something like this:

Welcome to Microsoft Graph!

Connected via userprovidedaccesstoken access using c288694f-2e16-4c20-928d-c262d8008520

How to reproduce

It's due to the latest Microsoft.Graph.Groups module that's just been released version 2.18.0- https://www.powershellgallery.com/packages/Microsoft.Graph.Groups/2.18.0

Running this instead in my script, to force it to use the previous version 2.17.0, it works:

if (-not(Get-Module -ListAvailable -Name Microsoft.Graph.Groups)) {
Install-Module -Name Microsoft.Graph.Groups -RequiredVersion '2.17.0' -Scope CurrentUser -AllowClobber -Force
Import-Module -Name Microsoft.Graph.Groups
}

SDK Version

2.18.0

Latest version known to work for scenario above?

2.17.0

Known Workarounds

Go back to the last known working version:

if (-not(Get-Module -ListAvailable -Name Microsoft.Graph.Groups)) {
Install-Module -Name Microsoft.Graph.Groups -RequiredVersion '2.17.0' -Scope CurrentUser -AllowClobber -Force
Import-Module -Name Microsoft.Graph.Groups
}

Debug output

Click to expand log ```
</details>


### Configuration

Windows, x64

### Other information

.
@marckean marckean added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Apr 25, 2024
@timayabi2020
Copy link
Collaborator

Hi @marckean thank you for reporting this issue. I successfully logged in after going through the reproduction steps. Kindly let me know which PowerShell version you are using.
image

@timayabi2020 timayabi2020 added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Apr 26, 2024
@marckean
Copy link
Author

I am using version 2.17.0 now, whereas before using version 2.18.0 failed for me.

I am running:

if (-not(Get-Module -ListAvailable -Name Microsoft.Graph.Groups)) {
Install-Module -Name Microsoft.Graph.Groups -Scope CurrentUser -AllowClobber -Force
Import-Module -Name Microsoft.Graph.Groups
}

Sign into the Microsoft Graph

$resource = "https://graph.microsoft.com"
$token = (Get-AzAccessToken -TenantId $tenantID -ResourceUrl $resource).Token

# Create a SecureString from the token
$SecureToken = ConvertTo-SecureString $token -AsPlainText -Force

# Use the SecureString token to connect
Connect-MgGraph -AccessToken $SecureToken

Note, as this doesn't specify a required version, it pulls the latest version (2.18.0). So adding this: -RequiredVersion '2.17.0' gets me past this error.

Also note, I am running this as an Azure Deployment Script resource which is executed using Bicep - for this, it spins up a container instance and runs the script.

@timayabi2020 timayabi2020 added Status: Needs Investigation and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Apr 26, 2024
@KnudsenMorten
Copy link

I'm experiencing same issue. Downgrading to v2.17 temporarily solves issue

@dp-h
Copy link

dp-h commented Apr 26, 2024

Same issue, downgrading to v2.17 is great workaround. My PS version info:

Name                           Value
----                           -----
PSVersion                      5.1.14393.6343
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.6343
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

@12Knocksinna
Copy link

Could this be a PowerShell 5 problem? I have no issue connecting with a user provided access token and using the Groups module with PS 7.4.2 and SDK 2.18.

@timayabi2020
Copy link
Collaborator

@12Knocksinna I also have no issue connecting from PowerShell 5.
image

@MainDBA
Copy link

MainDBA commented Apr 29, 2024

I have the same issue.
My Azure automation accounts update their PowerShell Modules automatically in the early hours each Monday morning and therefore I received the new Microsoft.Graph versions this morning advertised on the PowerShell gallery 4 days ago. Since then two automation accounts' runbooks (that have worked since I moved to Microsoft.Graph In October 2023) have errored this morning with similar errors (see below).
I use PowerShell Runtime version 5.1 and a User Managed Identity to authenticate - Cmdlets Get-MgGroup. Get-MgUser and Get-MgGroupMember have generated the following:

Error 1
Get-MgGroup : Method not found: 'Void Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[], Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'. At line:48 char:1 + $GroupID = Get-MgGroup -Filter "DisplayName eq 'everyone'" -Property ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-MgGroup_List], MissingMethodException + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgGroup_List

Error 2
Get-MgUser : Method not found: 'Void Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[], Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'. At line:49 char:1 + $users = Get-MgUser -All + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-MgUser_List], MissingMethodException + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgUser_List

Error 3
Get-MgGroupMember : Cannot bind argument to parameter 'GroupId' because it is an empty string. At line:50 char:39 + $members = Get-MgGroupMember -GroupId $GroupID.Id -All + ~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Get-MgGroupMember], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Get-MgGroupMember

@MainDBA
Copy link

MainDBA commented Apr 29, 2024

As suggested by @marckean , @KnudsenMorten and @dp-h I have manually reverted all 3 modules from version 2.18.0 back down to version 2.17.0 in my Azure Automation Account and my runbooks complete OK without any errors/messages.

If it assists anyone else having this issue in Azure Automation, to revert back to an older stable version:

  • Download the relevant older version's *.nupg files from the PowerShell Gallery for the affected Microsoft.Graphs. packages.
  • Rename the file as a *.zip
  • Delete version 2.18.0 module from your Azure Automation account
  • Import the module in the portal using "+ Add A Module" > "Browse for file" > Locate your downloaded zip > "Import"
    Just be wary of dependencies - you may have to do this for all your Microsoft.Graph modules and import them in a particular order (in my case it Authentication, then Users and finally Groups worked without any dependency warnings)

@timayabi2020
Copy link
Collaborator

I noticed that two versions of Azure.Identity assembly are loaded in a PowerShell session but PowerShell 5 doesn't seem to handle the conflict well hence throwing the AzureIdentityAccessTokenProvider constructor error. Microsoft Graph PowerShell SDK uses the latest versions of Azure.Identity and Azure.Identity.Broker assemblies (1.11.0 and 1.1.0 respectively) while the Az.Accounts module still uses the old Azure.Identity assembly (1.10.3).
I have seen a pull request in their GitHub repository to bump the Azure.Identity assembly up. The PR is yet to be merged.

So, if you are executing any scripts in a PowerShell 5 environment, please revert to 2.18.0 for now as suggested by @marckean, @KnudsenMorten, @dp-h and @MainDBA.

@peterboba
Copy link

peterboba commented May 7, 2024

This seems to be the same type of issue as #2148

PS C:\WINDOWS\system32> Import-Module Az.Accounts
PS C:\WINDOWS\system32> Import-Module Microsoft.Graph.Authentication
PS C:\WINDOWS\system32> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.19.0     Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear...
Script     2.18.0     Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, G...
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, En...
Script     2.0.0      PSReadline                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...


PS C:\WINDOWS\system32> Get-MgApplication
Get-MgApplication : Method not found: 'Void
Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[],
Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'.
At line:1 char:1
+ Get-MgApplication
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-MgApplication_List], MissingMethodException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgApplication_List

PS C:\WINDOWS\system32> Get-MgOrganization
Get-MgOrganization : Method not found: 'Void
Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[],
Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'.
At line:1 char:1
+ Get-MgOrganization
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-MgOrganization_List], MissingMethodException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgOrganization_List

But when you flip the order of imports - things work

PS C:\WINDOWS\system32> Import-Module Microsoft.Graph.Authentication
PS C:\WINDOWS\system32> Import-Module Az.Accounts
PS C:\WINDOWS\system32> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.19.0     Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear...
Script     2.18.0     Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, G...
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, En...
Script     2.0.0      PSReadline                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...


PS C:\WINDOWS\system32> Get-MgApplication
Get-MgApplication : Authentication needed. Please call Connect-MgGraph.
At line:1 char:1
+ Get-MgApplication
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-MgApplication_List], AuthenticationException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgApplication_List

@MainDBA
Copy link

MainDBA commented May 17, 2024

I noticed the Microsoft.Graph modules were updated to version 2.19.0 but this issue #2.18.0 was not included in the release notes - any updates on its progress please?

@Ndiritu
Copy link
Contributor

Ndiritu commented May 17, 2024

@MainDBA from the linked fix Azure PowerShell, the Az 12.0 release should resolve this.

@MainDBA
Copy link

MainDBA commented May 21, 2024

I spotted Az 12.0.0 was made available earlier today (21/05) on the PowerShell Gallery so I ran my module update script and also moved my MS.Graph modules from [working] version 2.17.0 to 2.19.0 and my two affected automation accounts' runbooks have run OK, so, issue [for me] appears to be resolved.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants