Currently, the Microsoft Graph API does not provide a direct way to filter managed devices by Azure AD group name within the managedDevice endpoint. The managedDevice object does not include group membership information, which means you cannot use a $filter query parameter to directly filter devices based on group names.
Recommended Approach:
- Query the Group Members: First, you can retrieve the members of the Azure AD group using the following endpoint:
This will return a list of users or devices that are members of the specified group.GET https://graph.microsoft.com/v1.0/groups/{group-id}/members - Match Device IDs: After obtaining the list of members, you can extract their IDs and then query the managed devices to find those that match the IDs of the group members. You can do this by querying the
managedDevicesendpoint and filtering based on the device IDs you retrieved from the group members.
This two-step approach allows you to correlate devices with their respective group memberships effectively, even though it requires an additional query.
Example Workflow:
- Get the group members:
GET https://graph.microsoft.com/v1.0/groups/{group-id}/members - Extract the device IDs from the response.
- Query managed devices:
GET https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?$filter=id in ({device-id1}, {device-id2}, ...)
This method ensures you can filter managed devices based on their group membership indirectly.
References: