Utilizing Remove-MgGroupMemberByRef to remove Specific user only from A group?

EnterpriseArchitect 5,406 Reputation points
2023-01-30T05:45:42.7733333+00:00

Hi People,

After reading: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.groups/remove-mggroupmemberbyref

Due to the lack of examples and documentation, I need some help using the Remove-MgGroupMemberByRef cmdlet.

I wanted to remove User1 from Az-Grp-Team1 which is an Azure cloud-only group.

How can I achieve this?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,226 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,577 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,070 questions
{count} votes

Accepted answer
  1. Vasil Michev 107.3K Reputation points MVP
    2023-01-30T07:54:22.55+00:00

    Something like this should do:

    Remove-MgGroupMemberByRef -GroupId 08900da5-xxxx-xxxx-xxxx-5af3b2f62a16 -DirectoryObjectId 584b2b38-xxxx-xxxx-xxxx-c9766cb4791b

    where you have to provide the GUIDs of both the group and the user you want to remove. You cannot provide either values, such as UPN, so use the Get-MGGroup/Get-MGUser cmdlets as needed beforehand to obtain the GUIDs.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.