Azure DevOps API returns incorrect number of members in AAD (Azure Active Directory) group

Viewed 99

I'm trying to write a PowerShell script that will generate a .csv of AAD users within an AAD group in my organisation.

I've been using the following Azure DevOps API - Memberships List with direction=down:

GET https://vssps.dev.azure.com/{organization}/_apis/graph/Memberships/{subjectDescriptor}?direction=down&api-version=6.1-preview.1)

Link to Azure Devops API Documentation

In order to try and get all the members of an AAD group, but it's not grabbing every member. For example, for one AAD group I can see 20 members within Azure DevOps (and Azure Portal), but the API only grabs 8 members. As far as I can tell, there isn't anything unique about these users. I've also tested it with a few other AAD groups - in each case, it doesn't seem to grab all the users.

Is there a different API call I should be using for this purpose, or is there a specific reason why all users aren't being grabbed? I'm quite new to DevOps, only been working about 3 months, so any help is appreciated and sorry if it's a stupid question.

Thanks!

1 Answers

You could double-check if all the members in this AAD group are:

-Invited as users in your Azure DevOps organization

enter image description here

-At least access once to this organization.

Since you are using this Azure DevOps Service API, to be considered as Members, they should be not only AAD group members but also should have Azure DevOps identity.

Related