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

RYAN FEATHERSTON 21 Reputation points

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: Thanks!

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

Accepted answer
  1. AndyLiu-MSFT 576 Reputation points


    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 "<deviceid>/memberOf"

    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,431 Reputation points

    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 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.