Forum Discussion
add user to SharePoint group via PowerShell error
This error usually isn’t very helpful because “Unknown Error” is generic, but there are a couple of common issues in your command. First, the -Site URL should be the actual site URL, not the admin URL. So instead of https://site1-admin.sharepoint.com/sites/company, try https://site1.sharepoint.com/sites/company. Second, in -LoginName don’t include mailto: it should just be the UPN/email address, for example: Add-SPOUser -Site https://site1.sharepoint.com/sites/company -Group "Company Info Members" -LoginName email address removed for privacy reasons
Also make sure that the user actually exists in your tenant (licensed or at least created) and that you’re a site collection admin on that site. PnP.PowerShell is great, but you don’t need it for this basic scenario—fixing the URL and login name is usually enough to get past this error.
------------------------------------
Don't forget to mark as solution if my answer suits you