In this Azure tutorial, we will discuss Azure AD group membership PowerShell. Apart from this, we will also discuss on the below topics
Table of Contents
Azure AD group membership PowerShell
We can use Get-AzureADGroupMember to get Azure AD group members using PowerShell.
Get-AzureADGroupMember
You can use this Azure PowerShell command to get Azure AD group members.
Syntax:
Get-AzureADGroupMember
-ObjectId <String>
[-All <Boolean>]
[-Top <Int32>]
[<CommonParameters>]
Parameters
-All
If the value is true, return all group members. If the value is false, return the number of objects
-ObjectId
It specifies the ID of a group in Azure AD to which the user belongs to.
-Top
It shows the maximum number of records to return.
Get-AzureADGroupMember Examples
You can use the command below to get the member details from the group in Azure active directory.
PS C:\windows\system32> Get-AzureADGroupMember
Once you execute the above command, it will ask you to enter the ObjectID (The ID of the AD group to which the user belongs)

Now enter the ObjectId, then run, and the output will be as below.
ObjectId DisplayName UserPrincipalName UserType
-------- ----------- ----------------- --------
ee09bfcd-36e9-47c2-a98c-cf19412540e6 Bks Sahoo bks@SPSkyTraining.onmicrosoft.com Member
You can check out the below screenshot to see the same output.

You can also use the command in the below format.
PS C:\windows\system32> Get-AzureADGroupMember -ObjectId "23359f6d-850e-47e3-96b3-6ccae2ecb7bd"
You can mention the ObjectId with the Get-AzureADGroupMember command inline.

Output will be
ObjectId DisplayName UserPrincipalName UserType
-------- ----------- ----------------- --------
ee09bfcd-36e9-47c2-a98c-cf19412540e6 Bks Sahoo bks@SPSkyTraining.onmicrosoft.com Member
Note:
Before running the above commands, You need to connect to Azure using the below command
PS C:\windows\system32> Connect-AzureAD

PowerShell command to get Azure ad group members
If you want to get the existing members belonging to a group, you can use the Get-AzureADGroupMember command.
The syntax is
Get-AzureADGroupMember -ObjectId <String> [-All <Boolean>] [-Top <Int32>] [<CommonParameters>]
PS C:\Windows\system32> Get-AzureADGroupMember -ObjectId 219b773f-bc3b-4aef-b320-024a2eec0b5b
The output will be
ObjectId DisplayName UserPrincipalName UserType
-------- ----------- ----------------- --------
ee09bfcd-36e9-47c2-a98c-cf19412540e6 Bks Sahoo bks@SPSkyTraining.onmicrosoft.com Member

PowerShell command to remove Azure AD group members
You can remove the member we previously added to the group. We can use the Remove-AzureADGroupMember.
PS C:\Windows\system32> Remove-AzureADGroupMember -ObjectId f21bae22-8ac0-780c-bc37-udae0f3da61i -MemberId ee09bfcd-36e9-47c2-a98c-cf19412540e6
You may like the following Azure tutorials:
- The term ‘get-azureadgroup’ is not recognized as the name of a cmdlet
- No match was found for the specified search criteria and module name ‘AzureAD’
- How to create and add members to Azure Active Directory Group
- Azure Domain name service
Conclusion
In this Azure tutorial, We discussed the steps to get Azure AD group members using PowerShell.
I am Bijay, a Microsoft MVP (10 times) having more than 17 years of experience in the software industry. During my IT career, I got a chance to share my expertise in SharePoint and Microsoft Azure, like Azure VM, Azure Active Directory, Azure PowerShell, etc. I hope you will learn from these Azure tutorials. Read more