Skip to content

'Method not found' exception when running Move-MgUserMessage #187

@Windos

Description

@Windos

I've just updated to Microsoft.Graph 0.5.0 and tried using Move-MgUserMessage from Microsoft.Graph.Users.Actions.

When run, I get a Method not found exception calling out System.Net.Http.HttpClient Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers.GetGraphHttpClient(Microsoft.Graph.PowerShell.Authentication.IAuthContext)

I have observed this with both Windows PowerShell 5.1 and PowerShell 7.1 Preview 2

I had previously been running 0.2.1 of the Microsoft.Graph module suite and ran Update-Module Microsoft.Graph to update.

Full (redacted) code

$Cert = 'THUMBPRINT'
$AppId = 'GUID'
$TenantId = 'GUID'
$User = 'user@example.com'

$TestingFolder = 'FolderID'
$UnknownFolder = 'FolderID'

Connect-Graph -CertificateThumbprint $Cert -ClientId $AppId -TenantId $TenantId

$Messages = Get-MgUserMailFolderMessage -UserId $User -MailFolderId $TestingFolder
$Messages.Count

foreach ($Mail in $Messages) {
    Move-MgUserMessage -MessageId $Mail.Id -DestinationId $UnknownFolder
}

$Messages = Get-MgUserMailFolderMessage -UserId $User -MailFolderId $TestingFolder
$Messages.Count

Error

PS C:\Windows\System32> Get-Error

Exception             :
    Type       : System.MissingMethodException
    Message    : Method not found: 'System.Net.Http.HttpClient
Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers.GetGraphHttpClient(Microsoft.Graph.PowerShell.Authentication.IAuthContext)'.
    TargetSite :
        Name          : BeforeCreatePipeline
        DeclaringType : Microsoft.Graph.PowerShell.Module, Microsoft.Graph.Users.Actions.private, Version=0.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : Microsoft.Graph.Users.Actions.private.dll
    StackTrace :
   at Microsoft.Graph.PowerShell.Module.BeforeCreatePipeline(InvocationInfo invocationInfo, HttpPipeline& pipeline)
   at Microsoft.Graph.PowerShell.Module.CreatePipeline(InvocationInfo invocationInfo, String parameterSetName)
   at Microsoft.Graph.PowerShell.Cmdlets.MoveMgUserMessage_MoveExpanded.ProcessRecordAsync()
    Source     : Microsoft.Graph.Users.Actions.private
    HResult    : -2146233069
CategoryInfo          : NotSpecified: (:) [Move-MgUserMessage_MoveExpanded], MissingMethodException
FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.MoveMgUserMessage_MoveExpanded
InvocationInfo        :
    MyCommand        : Move-MgUserMessage_MoveExpanded
    ScriptLineNumber : 2
    OffsetInLine     : 5
    HistoryId        : 10
    Line             :     Move-MgUserMessage -MessageId $Mail.Id -UserId $User -DestinationId $UnknownFolder

    PositionMessage  : At line:2 char:5
                       +     Move-MgUserMessage -MessageId $Mail.Id -UserId $User -Destination …
                       +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Move-MgUserMessage
    CommandOrigin    : Internal
ScriptStackTrace      : at Move-MgUserMessage<Process>, C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Users.Actions\0.5.0\exports\ProxyCmdletDefinitions.ps1: line 26239                               at <ScriptBlock>, <No file>: line 2
PipelineIterationInfo :

Environment

Windows PowerShell 5.1

PS C:\Users\Windos> $PSVersionTable

Name                           Value                                                                                                                                                            
----                           -----                                                                                                                                                            
PSVersion                      5.1.18362.752                                                                                                                                                    
PSEdition                      Desktop                                                                                                                                                          
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                          
BuildVersion                   10.0.18362.752                                                                                                                                                   
CLRVersion                     4.0.30319.42000                                                                                                                                                  
WSManStackVersion              3.0                                                                                                                                                              
PSRemotingProtocolVersion      2.3                                                                                                                                                              
SerializationVersion           1.1.0.1  
ModuleType Version    Name                                ExportedCommands                                                                                                                      
---------- -------    ----                                ----------------                                                                                                                      
Script     1.0.0.0    ISE                                 {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}                                                                                   
Script     0.2.0      Microsoft.Graph.Authentication      {Connect-Graph, Disconnect-Graph, Get-MgContext}                                                                                      
Script     0.5.0      Microsoft.Graph.Users.Actions       {Clear-MgUserAndBlockManagedApp, Clear-MgUserManagedAppRegistration, Clear-MgUserManagedDevice, Clear-MgUserWindowInformationProtec...
Script     0.2.1      Microsoft.Graph.Users.Mail          {Get-MgUserInferenceClassification, Get-MgUserInferenceClassificationOverride, Get-MgUserMailFolder, Get-MgUserMailFolderChildFolde...
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                                                                    
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}                                             
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, Enable-WSManCredSSP...}        

PowerShell 7.1

PS C:\Windows\System32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.1.0-preview.2
PSEdition                      Core
GitCommitId                    7.1.0-preview.2
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
PS C:\Windows\System32> Get-Module

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     0.2.0                 Microsoft.Graph.Authentication      {Connect-Graph, Disconnect-Graph, Get-MgContext}
Script     0.5.0                 Microsoft.Graph.Users.Actions       {Clear-MgUserAndBlockManagedApp, Clear-MgUserManagedAppRegistration, Clear-MgUserManagedDevice, Clear-MgUserWindowInf… 
Script     0.2.1                 Microsoft.Graph.Users.Mail          {Get-MgUserInferenceClassification, Get-MgUserInferenceClassificationOverride, Get-MgUserMailFolder, Get-MgUserMailFo… Manifest   7.0.0.0               Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…}
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object…}
Script     2.0.1                 PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler…}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions