Why is Add-SPOUser parameter Group null?

Machiel Korf | Korf KB 20 Reputation points
2024-03-27T10:25:26.39+00:00

I am working on adding templates in Microsoft 365 via Sharepoint and running this via Windows Powershell. So far so good. Now I want to run the script to "set" the template folder and permissions so that it is shown in the office environment.

On the following script I get an error, group is NULL

Add-SPOUser -Site $SharePointSiteUrl -LoginName ('c:0-.f|rolemanager|spo-grid-all-users/{0}' -f $AzureAdTenantId) -Group $SpoGroupVisitor.LoginName;

What am I doing wrong? Or do I need to create another group of users somewhere?

Error message is this:

Add-SPOUser : Cannot bind argument to parameter 'Group' because it is null.

At line:1 char:122

  • ... ll-users/{0}' -f $AzureAdTenantId) -Group $SpoGroupVisitor.LoginName;
    • CategoryInfo : InvalidData: (:) [Add-SPOUser], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Online.SharePoint.PowerShell.AddSPOUser

would like to hear.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,628 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,799 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yanli Jiang - MSFT 21,606 Reputation points Microsoft Vendor
    2024-03-28T06:29:13.7633333+00:00

    Hi @Machiel Korf | Korf KB

    The error message suggests that the value of the Group parameter is null, which means that it is not being set or passed correctly in the script.

    It is possible that the variable $SpoGroupVisitor is not being set correctly or is null. You may need to check the value of this variable and ensure that it is being set to a valid SharePoint group before running the Add-SPOUser cmdlet.

    Alternatively, you may need to create a new SharePoint group and add users to it before running the Add-SPOUser cmdlet.

    For your reference:

    Manage SharePoint users and groups with PowerShell


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful