Query Details
# Role Report ## Query Information #### Description This query can be used to draw an report of the Entra ID role memberships for all users. ## Defender XDR ```KQL let TimeFrame = 30d; IdentityInfo | where Timestamp > ago(TimeFrame) | summarize arg_max(TimeGenerated, *) by AccountObjectId | mv-expand AssignedRoles | where isnotempty(AssignedRoles) | summarize TotalRoles = dcount(tostring(AssignedRoles)), MemberOf = make_set(tostring(AssignedRoles), 1000) by AccountObjectId, AccountDisplayName, AccountUPN | extend ReportDate = now() | sort by TotalRoles desc ``` ## Sentinel ```KQL let TimeFrame = 30d; IdentityInfo | where TimeGenerated > ago(TimeFrame) | summarize arg_max(TimeGenerated, *) by AccountObjectId | mv-expand AssignedRoles | where isnotempty(AssignedRoles) | summarize TotalRoles = dcount(tostring(AssignedRoles)), MemberOf = make_set(tostring(AssignedRoles), 1000) by AccountObjectId, AccountDisplayName, AccountUPN | extend ReportDate = now() | sort by TotalRoles desc ```
This query generates a report of Entra ID role memberships for all users over the past 30 days. Here's a simplified breakdown of what the query does:
The result is a list of users with their display names, user principal names (UPNs), the total number of roles they have, the specific roles they are members of, and the date the report was generated.

Bert-Jan Pals
Released: August 26, 2024
Tables
Keywords
Operators