pnp / PnP

SharePoint / Office 365 Developer Patterns and Practices - Archived older solutions. Please see https://aka.ms/m365pnp for updated guidance
https://aka.ms/m365pnp
Other
1.9k stars 3.31k forks source link

Method not found running Add-PnPMicrosoft365GroupMember #1951

Closed mikeparkie closed 2 years ago

mikeparkie commented 3 years ago

Category: Bug [✔] Environment: Office 365 / SharePoint Online [✔] Connecting from Windows Server 2008 R2 PnP.PowerShell 1.6.0 [PowerShell Gallery with Install-Module] Microsoft.Online.SharePoint.PowerShell 16.0.21213.12000 [PowerShell Gallery with Install-Module]

As part of our site provisioning script we add new site admins to our site admins Yammer group using: Add-PnPMicrosoft365GroupMember -Identity "sitename" -Users "user.name@company.domain"

This runs fine on several of our machines, other than one where it produces the following error:

Add-PnPMicrosoft365GroupMember : Method not found: 'System.Net.Http.HttpClient PnP.Framework.Http.PnPHttpClient.GetHttpClient()'.
At line:1 char:1
+ Add-PnPMicrosoft365GroupMember -Identity "sitename" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-PnPMicrosoft365GroupMember], MissingMethodException
    + FullyQualifiedErrorId : System.MissingMethodException,PnP.PowerShell.Commands.Microsoft365Groups.AddMicrosoft365GroupMember

Reading this #1741 I attempted the following steps:

Deleted all the SharePoint Components from the Control Panel (Add/Remove) Removed all SharePoint items from (C:\windows\Microsoft.NET\assembly\GAC_MSIL), Uninstalled both PS modules and reinstalled again Restarted the machine

Retried original command and it's still producing the same error.

Any ideas appreciated, TIA

tonylanglet commented 3 years ago

I had a similar problem to the issue you linked to, where I got told that the Method that was being called didn't exists. I did some diging and found out that the server that I ran the script from (Connect-PnPOnline) did not have .NET Core installed on it.

I installed .NET Core 3.1 Runetime and it seemed to solve the issue as the Methods I required were located in the .NET Core.

mikeparkie commented 3 years ago

Thanks for the suggestion @tonylanglet I gave that a go, rebooted the server and rerun the commands. Same errors. Alas the digging continues.

mikeparkie commented 2 years ago

We found that two of our severs were missing .Net 4.8. Updated both/rebooted and commands now complete correctly 👍😎. Closing the issue.