Add-EntraGroupMember
Add a member to a security or Microsoft 365 group.
Syntax
Add-EntraGroupMember
-GroupId <String>
-MemberId <String>
[<CommonParameters>]
Description
The Add-EntraGroupMember
cmdlet adds a member to a security or Microsoft 365 group.
In delegated scenarios, the signed-in user needs a supported Microsoft Entra role or a custom role with the microsoft.directory/groups/members/update
permission. The minimum roles required for this operation, excluding role-assignable groups, are:
- Group owners
- Directory Writers
- Groups Administrator
- User Administrator
Examples
Example 1: Add a member to a group
Connect-Entra -Scopes 'GroupMember.ReadWrite.All'
$group = Get-EntraGroup -Filter "DisplayName eq 'Contoso Marketing Group'"
$user = Get-EntraUser -UserId 'SawyerM@contoso.com'
Add-EntraGroupMember -GroupId $group.Id -MemberId $user.Id
This example demonstrates how to add a member to a group.
-GroupId
- Specifies the unique identifier (Object ID) of the group to which you want to add a member.-MemberId
- Specifies the unique identifier (Object ID) of the member to be added to the group. You can add users, security groups, Microsoft 365 groups, devices, service principals, and organizational contacts to security groups. Only users can be added to Microsoft 365 groups.
Parameters
-GroupId
Specifies the ID of a group in Microsoft Entra ID.
Type: | System.String |
Aliases: | ObjectId |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-MemberId
Specifies the unique identifier (Object ID) of the member to be added to the group. You can add users, security groups, Microsoft 365 groups, devices, service principals, and organizational contacts to security groups. Only users can be added to Microsoft 365 groups.
Type: | System.String |
Aliases: | RefObjectId |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |