Close Menu
    Facebook X (Twitter) Instagram
    Monday, June 23
    X (Twitter) LinkedIn
    All about Endpoint Management
    • Home
    All about Endpoint Management
    Home»Intune»PowerShell Script: Extract Entra ID Group Members with Graph Command

    PowerShell Script: Extract Entra ID Group Members with Graph Command

    Eswar KonetiBy Eswar KonetiMay 17, 11:02 pm3 Mins Read Intune 996 Views
    Share
    Facebook Twitter LinkedIn Reddit

    Exporting entra ID group members (transitivemember) with PowerShell:

    Recently, while working with Intune deployments, I was asked to extract devices from a specific group into a CSV format. This task seemed straightforward, but the problem arose when attempting to gather all members, including those within nested groups.

    While the Intune or Entra ID portal offers a convenient option to export members using direct members, bulk operations, and a simple click on "Download members," it falls short when it comes to exporting devices associated with nested groups. This limitation spurred the exploration of alternative methods, leading to the discovery of PowerShell as a powerful solution.

    The following screenshot shows how you can download the direct members using the Entra ID or intune console.

    image

    If you want to download all members using the console, there is no download members available.

    image

    Exporting Members with PowerShell

    Unlike the portal's constraints, PowerShell enables us to extract comprehensive device details not available through direct member downloads. Leveraging the Microsoft Graph command Get-MgGroupTransitiveMember, part of the "Microsoft.Graph.Groups" module, we gain access to an array of device information crucial for deployment scenarios.

    Before diving into the script execution, ensure that the executing account have the necessary graph permissions, primarily read access. Without adequate permissions, Graph may restrict access, hindering the script's functionality.

    For more information about the Powershell command and module, please refer https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.groups/get-mggroup?view=graph-powershell-1.0

    image

    image

    Script Overview

    The script's functionality extends beyond the portal's limitations, empowering users to export both direct and nested group members effortlessly. Here's a concise breakdown of its operation:

    1. Module Validation: The script verifies the presence of the Entra ID groups module and installs it if absent, ensuring seamless execution.
    2. Graph API Connection: Establishing a connection to the Microsoft Graph API with requisite permissions is vital for accessing Entra ID group data.
    3. User Input: User is prompted to input the Entra ID group name, facilitating targeted member extraction.
    4. Data Extraction: Upon validation, the script retrieves the group's ID and exports member details to a CSV file. This file encompasses crucial device information such as name, operating system, creation date, registration date, last sign-in date, and device ID.

    The script is uploaded to Github repository for download.

    Screenshots of the script execution and output data.

    image

    Output:

    image

    image

    Conclusion

    In summary, PowerShell serves as a robust tool for circumventing portal limitations and extracting comprehensive device data for deployment purposes. By leveraging the Get-MgGroupTransitiveMember command, users can streamline Intune deployments and fulfill requests for exporting all devices associated with Entra ID groups.

    Reference article:

    Get-MgGroupTransitiveMember (Microsoft.Graph.Groups) | Microsoft Learn

    all members EntraID Export Export devices Intune devices Powershell
    Share. Twitter LinkedIn Email Facebook Reddit

    Related Posts

    Optimize Your Intune Workflow with a Powerful Browser Extension

    March 22, 10:39 am

    Troubleshooting Windows Hello for Business PIN Reset Issues – Something went wrong

    March 06, 9:48 pm

    Migrate Microsoft 365 Updates from SCCM/MECM to Intune for Co-Managed Devices

    February 11, 9:50 pm

    Leave a ReplyCancel reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Sign Up

    Get email notifications for new posts.

    Author

    I’m Eswar Koneti ,a tech enthusiast, security advocate, and your guide to Microsoft Intune and Modern Device Management. My goal? To turn complex tech into actionable insights for a streamlined management experience. Let’s navigate this journey together!

    Support

    Awards

    Archives

    © Copyright 2009-2024 Eswar Koneti, All rights reserved.

    Type above and press Enter to search. Press Esc to cancel.