Home ยป Office 365 ยป Remove-MsolGroupMember – Remove Members from Office 365 Group

Remove-MsolGroupMember – Remove Members from Office 365 Group

The Remove-MsolGroupMember command in PowerShell removes a member from a security group in Office 365. This member can be either a user or a group.

The syntax to remove a member from the specific security group in Office 365 is given below.

Remove-MsolGroupMember
      -GroupObjectId <Guid>
      [-GroupMemberType <GroupMemberType>]
      [-GroupMemberObjectId <Guid>]
      [-TenantId <Guid>]
      [<CommonParameters>]

In this article, we will discuss how to use the Remove-MsolGroupMember cmdlet in PowerShell to remove a member from the Office 365 group.

How to Remove a User from a Group in Office 365

To remove a user from a Group in Office 365, use the Remove-MsolGroupMember cmdlet. This command uses the -GroupObjectId to specify the groupId. The -GroupMemberObjectId parameter specifies userId and the -GroupMemberType parameter specifies the User type.

# Get the User
$User = Get-MsolUser -UserPrincipalName "[email protected]" 

# Get the Group object in Office 365 
$Group = Get-MsolGroup -ObjectId "008f363f-5b3a-4899-8004-a2d140426802"

# Add a new user to the security group
Remove-MsolGroupMember -GroupObjectId $Group.ObjectId -GroupMemberObjectId $User.ObjectId -GroupMemberType User 

In this example, the Remove-MsolGroupMember cmdlet removes a user with a user principal name โ€œ[email protected]โ€ from the group in Office 365.

Conclusion

I hope the above article on how to use the Remove-MsolGroupMember cmdlet in PowerShell to remove a member from the security group in Office 365 is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.

Related Links

Add-MsolGroupMember

Get-MsolGroupMember