Add-PnPGroupMember won't map a user

Copper Contributor

With the following command I will entitle our users to a specfic site:

Connect-PnPOnline -Url https://xxx.sharepoint.com/sites/yyy -Credentials $userCredential2
$groupMember = Get-PnPGroup -AssociatedMemberGroup
$gruppennameM = $groupMember.Title
$groupid = $groupMember.Id
Add-PnPGroupMember -LoginName user@company.com -Group $groupid

 

After sending command above I get the following error:
Add-PnPGroupMember : Method not found: "Int32 System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8(System.ReadOnlySpan`1)".

 

The command is full correct, the ID of the group is correct and the user is correct.
Why does the command not work for me ?

 

2 Replies
Hello,

I had the same issue when running my script from VS Code, no problem in PowerShell command prompt.
Thank you Niicoo, this helped me too!