Using Azure CLI we can retrieve a list of objectIds in a Azure Active Directory group.


Install the Azure CLI if it’s not already installed.

If you aren’t currently logged in with Azure CLI run:

> az login

Retrieving ObjectIds

Now, you’re ready to get the objectIds!

> az ad group member list --group "GROUP_NAME_HERE" --query "[].{displayName: displayName, userPrincipalName: userPrincipalName, objectId: objectId}" --output table
DisplayName  UserPrincipalName  ObjectId
-----------  -----------------  ------------------------------------
Test User 1  [email protected]  00000000-0000-0000-0000-000000000001
Test User 2  [email protected]  00000000-0000-0000-0000-000000000002

If you’re looking for a comma separated value:

> az ad group member list --group "GROUP_NAME_HERE" --query "[].objectId | {objectIds: join(',', @)}"
  "objectIds": "00000000-0000-0000-0000-000000000001,00000000-0000-0000-0000-000000000002"