How to Add a User to a SharePoint Group? A Complete Guide
To manage the SharePoint permissions efficiently, SharePoint administrators created the groups. These groups are created according to the needs of the organization such as project tracking. SharePoint administrators took advantage of creating the groups by assigning permissions at the group level instead of individual users. It reduces the overburden of the SharePoint administrators. However, the task is not completed just by creating the groups, adding users to it is a major task. In this guide, you will get to know several methods on how to add a user to a SharePoint group.
So, let’s get started.
Method 1. Add User in SharePoint Group Using SharePoint Admin Center
If you are a regular user of SharePoint and comfortable with the user interface of the SharePoint admin center. Then execute the below steps.
- Open SharePoint Online using the right credentials.
- Move to the Settings option > Site Permissions.
- Open the Advanced permissions settings.
- From the Permissions Tab, choose the group where you want to add the users.
- After finalizing the group, click on the New option and then select Add Users.
- Now search the names of the users that should be added to the group.
- After selecting the users to be added to the SharePoint group, click on the Share button.
Method 2. How to Add a User to a SharePoint Group Using PowerShell?
If you are well-versed in the PowerShell commands and want to automate the process, then use the below commands. Execute them in a sequential manner because the wrong execution of the commands can lose your data.
$web=Get-SPWeb “enter the web address" $Name_Group= $web.Groups["Technical"] $Name_User = "domain\userName" $user = $web.EnsureUser($Name_User) $Name_Group.AddUser($user)
Method 3. PnP PowerShell to Add Group Members in SharePoint Online
This script first cross-checks whether the user is already in the SharePoint group. If it is not present, then it will add the user to the group.
$Site_URL = "complete site URL" $NameofGroup = "purchase Members" $userID = "enter here" Connect-PnPOnline -Url $Site_URL -Interactive $MembersofGroup = Get-PnPGroupMember -Identity $NameofGroup | Select-Object -ExpandProperty Email if ($MembersofGroup -contains $userID) { Write-Host "$UserID is already a member of $NameofGroup." } else { Write-Host "$userID is not a member of $NameofGroup. Adding..." Add-PnPGroupMember -LoginName $UserID -Identity $NameofGroup }
Method 4. How to Add a User to a SharePoint Group Using Power Automate?
Power Automate flow is not supported as a direct action to add the users to the SharePoint groups. So, you need to send the HTTP request along with the ID of group and user email.
Method: POST
Uri:
_api/web/siteGroups/GetById()/usersHeaders:
{
“accept”: “application/json;odata=verbose”,
“content-type”: “application/json;odata=verbose”
}Body:
{
“__metadata”: {
“type”: “SP.User”
},
“LoginName”: “i:0#.f|membership|”
}
Method 5. Add User to SharePoint Group Using Rest API
Use the correct Login name of the user with the appropriate SharePoint GroupID.
<script type=”text/javascript” srchttps://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js”>
</script> <button type=”button” onclick=”addUserToGroup()”> Add User To Group </button>
<script type=”text/javascript”>
function addUserToGroup() { var addUserToGroupEndpoint = _spPageContextInfo.webAbsoluteUrl + “/_api/web/sitegroups(38)/users”;
var payload = JSON.stringify({ ‘__metadata’: { ‘type’: ‘SP.User’ },
‘LoginName’: ‘i:0#.f|membership|[email protected]’ });
$.ajax({ url: addUserToGroupEndpoint, type: “POST”,
data: payload, headers: { “X-RequestDigest”: $(“#__REQUESTDIGEST”).val(), “accept”: “application/json;odata=verbose”, “content-type”: “application/json;odata=verbose” }, success: function (data) { console.log(“User Added to Group successfully!”); }, error: function (error) { console.log(error); } }); } </script>
However, creating and managing the SharePoint groups is the right way to fulfill the SharePoint document management best practices. But sometimes, users perform some unethical activities within the SharePoint group. These activities can harm the SharePoint data, so to avoid data loss you should perform SharePoint Online tenant to tenant migration. This can be done using the SysTools Most Efficient SharePoint Migrator.
This professional tool can help you to shift your crucial SharePoint data to another account.
Conclusion
In this detailed write-up, we have successfully found the answer to how to add a user to a SharePoint group query. Here we have discussed several methods through which you can easily add the essential users into the SharePoint groups. Now, pick the one that seems simple to use and accomplish your task.