How to Export PIM Role Assignments in Entra ID

How to Export PIM Role Assignments in Entra ID

Last Updated

August 11, 2025

Posted In

In this blog post, I’ll walk you through the steps to export PIM role assignments in Entra ID. If you’re an administrator looking to analyze role assignments, generate compliance reports, or maintain an audit trail, this guide is for you.

The Privileged Identity Management (PIM) enables organizations to manage just-in-time (JIT) access to critical resources to privileged roles, ensuring that users only have elevated access when absolutely necessary. The resources include Microsoft Entra ID, Azure, and other Microsoft Online Services such as Microsoft 365 or Microsoft Intune.

There are two ways to export Entra ID PIM role assignments: Entra Admin center and PowerShell. With Powershell you can individually export eligible and assigned PIM role assignments while with Entra admin center, you can export all the PIM assignments at once.

Install and Update Third Party Applications with Patch My PC
Install and Update Third Party Applications with Patch My PC

Exporting Entra PIM role assignments to a CSV file allows you to analyze which users have been granted privileged roles. Administrators can utilize this report to identify users assigned with PIM roles that may no longer be necessary.

Why Export Entra ID PIM Role Assignments?

From an organization’s security standpoint, regularly auditing role assignments in Entra ID is crucial to ensure that permissions are appropriately granted to the right users, groups, or applications. Exporting PIM roles proves valuable in various scenarios:

  1. Compliance and Reporting: Many organizations are required to provide access reports for audits.
  2. Access Reviews: When you export PIM role assignments, it helps to identify users with unnecessary or excessive permissions.
  3. Governance: Ensures that privileged accounts are managed in line with organizational policies.

Prerequisites

  1. Entra ID Global Administrator
  2. Install the latest Microsoft Graph PowerShell module
  3. PowerShell version 7 or newer
  4. Microsoft Excel app to view the CSV file data

Export PIM Role Assignments from Entra Admin Center

The easiest way to export all the PIM role assignments is from Microsoft Entra Admin center. First, sign in to the Microsoft Entra Admin Center. Navigate to ID Governance > Privileged Identity Management > Microsoft Entra Roles.

Export PIM Role Assignments from Entra Admin Center
Export PIM Role Assignments from Entra Admin Center

Under Manage, select Roles. Now you should see all the PIM roles listed on the right-hand side. Click on Export option.

Export PIM Role Assignments in Entra ID
Export PIM Role Assignments in Entra ID

The file will be prepared for the download. Click on the Download button and your browser downloads ‘RoleAssignments.csv‘ file that contains all the Entra ID PIM role assignments.

Export PIM Role Assignments in Entra ID
Export PIM Role Assignments in Entra ID

Open the PIM role assignment report (RoleAssignments.csv) with an Excel app. It includes the following information:

  • Assignment State
  • User Group Name
  • Role Name
  • Email
  • Principal Name
  • Member Type
  • Assignment Start Time
  • Assignment End Time

Through this file, you can find out users that are assigned with privileged roles and conduct access reviews to ensure users still need roles.

From my experience, I can tell you that PIM assignments can be permanent, but they are more often time-bound. This enables administrators to carry out tasks on a just-in-time basis without requiring their accounts to have continuously elevated permissions.

Details of Entra ID RoleAssignments.csv
Details of Entra ID RoleAssignments.csv

Export Entra ID PIM Assignments using PowerShell

In this method, I will show you how to export PIM role assignments to a CSV file using PowerShell. Although this approach is slightly more complex than the previously discussed method, it retrieves the data much faster and more effortlessly.

Note: GitHub offers various scripts that can generate a CSV report combining eligible and assigned PIM roles. However, during my testing, I found that some scripts were outdated and non-functional, while others required minor adjustments to work effectively.

Step 1: Install the Microsoft Graph Module

Ensure you have the Microsoft Graph module installed. Run the following commands to install and import the module:

Install-Module Microsoft.Graph -Scope AllUsers -Repository PSGallery -Force
Install the Microsoft.Graph Module
Install the Microsoft Graph Module

Step 2: Connect to Microsoft Entra ID

Next, run the following command to authenticate and connect to Entra ID. In the below example, I have authenticated using an Entra ID Global Administrator account.

Connect-MgGraph -Scopes "RoleManagement.Read.All"
Connect to Microsoft Entra ID
Connect to Microsoft Entra ID

Step 3: Export Eligible PIM role assignments

The Get-MgRoleManagementDirectoryRoleEligibilitySchedule retrieves the schedule for a role eligibility operation. Run the below command to retrieve all the eligible PIM role assignments and export it to a file named “EligiblePIMRoles.csv“.

Get-MgRoleManagementDirectoryRoleEligibilitySchedule | Export-Csv -Path "C:\EligiblePIMRoles.csv"
Export Eligible PIM role assignments
Export Eligible PIM role assignments

Step 4: Export Assigned PIM role assignments

The Get-MgRoleManagementDirectoryRoleAssignmentSchedule retrieves the schedule for a role eligibility operation. Run the below command to retrieve all the assigned PIM role assignments and export it to a file named “AssignedPIMRoles.csv“.

Get-MgRoleManagementDirectoryRoleAssignmentSchedule | Export-Csv -Path "C:\AssignedPIMRoles.csv"
Export Assigned PIM roles assignments
Export Assigned PIM roles assignments

That’s all I wanted to cover in this guide. If you need any clarification or suggestions related to this post, please let me know in the comments section.

Leave a Reply

Your email address will not be published. Required fields are marked *

Prajwal Desai

Prajwal Desai is a highly accomplished technology expert and an 11-time Dual Microsoft MVP (Most Valuable Professional), specializing in Microsoft Intune, SCCM, Windows 365, Enterprise Mobility, and Windows. As a renowned author, speaker, and community leader, he is widely recognized for sharing his in-depth expertise and insights through his blog, YouTube channel, conferences, webinars, and other platforms.