How to add Security groups to Sharepoint groups?

Romian Tairovski 21 Reputation points


I'm creating a Microsoft Team programmatically, via Graph Calls. After creating a Team, a sharepoint is automatically created and I'm creating a folder structure in the Sharepoint.

I want to add security groups to the sharepoint groups

In the screenshot below you see the Sharepoint Groups

Here you can see I can add a security group to the Sharepoint group by useing the user interface.

This all works, but I want to do it programmatically. Are there Graph calls I can use? Or do I need to use Powershell or C#?

Thanks for reading and I hope someone can help.

Romian Tairovski

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,049 questions
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 32,646 Reputation points Microsoft Vendor

    Hi @Romian Tairovski ,
    I will recommend you to use PowerShell, in which case your best bet is the Add-SPOUser cmdlet, which "Adds an existing Office 365 user or an Office 365 security group to a SharePoint group."
    Here is the example

    $SecGroupName = "TestSecurityGroup"        # The security group DisplayName  
    $SPOGroupName = "TestSharePointGroup"      # The SharePoint Online group  
    # Get the SharePoint site  
    $SPOSite = Get-SPOSite ""  
    # Add the security group as a member of the SharePoint Online group  
    Add-SPOUser -Site $SPOSite -LoginName $SecGroupName -Group $SPOGroupName  

    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.

0 additional answers

Sort by: Most helpful