How to use powershell to list a device membership for Intune / Azure AD?

RYAN FEATHERSTON 21 Reputation points
2020-09-30T20:18:31.177+00:00

I'm just looking for a way to easily return what an Intune device has for group memberships. I can only seem to find this in the GUI of Intune for EDU. Surely there has to be a way. It would make sense to have a PowerShell cmdlet Get-AzureADDeviceMembership. (This doesn't exist) There is Get-AzureADUserMembership that works for users but I need one for devices. A user from another forum was looking for this last year. I'm looking exactly for what he is talking about. Here is that post: https://stackoverflow.com/questions/57251857/azure-active-directory-how-to-check-device-membership Thanks!

Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
4,743 questions
0 comments No comments
{count} votes

Accepted answer
  1. AndyLiu-MSFT 586 Reputation points
    2020-10-01T07:19:29.823+00:00

    @RYAN FEATHERSTON

    You can use the Graph API List device groups method in PowerShell. Please view the following code for reference.

    Install-Module -Name Microsoft.Graph
    Connect-Graph -Scopes "User.Read.All", "Group.ReadWrite.All", "Device.Read.All"
    $DeviceGroupData = Invoke-GraphRequest -Uri "https://graph.microsoft.com/v1.0/devices/<deviceid>/memberOf"
    $DeviceGroupData.value.displayName

    Please replace the <deviceid> with the real one.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Nick Hogarth 3,436 Reputation points
    2020-09-30T22:22:57.837+00:00

    I am not sure how to do it using PowerShell off the top of my head, but you can view this in the portal now. If you login to https://aad.portal.azure.com/ then go to Devices and select the Device, if you scroll down to Groups it lists the Azure AD Groups that the device is a member of.

    1 person found this answer helpful.