Detect privileged role assignment in Entra ID (KQL)
Adding an account to a directory role such as Global Administrator or Privileged Role Administrator is a direct privilege escalation and a favourite persistence move after a tenant compromise. This AuditLogs query returns "Add member to role" operations, resolves who performed the change and who was added, and extracts the role name from the audited modifiedProperties.
Review every hit: role assignments should be rare, deliberate and traceable to a change request.
The query
AuditLogs
| where TimeGenerated > ago(24h)
| where OperationName == "Add member to role"
| extend Actor = coalesce(
tostring(InitiatedBy.user.userPrincipalName),
tostring(InitiatedBy.app.displayName))
| mv-expand TargetResources
| extend TargetUser = tostring(TargetResources.userPrincipalName)
| mv-apply mp = TargetResources.modifiedProperties on (
where tostring(mp.displayName) == "Role.DisplayName"
| project RoleName = trim('"', tostring(mp.newValue))
)
| project TimeGenerated, Actor, TargetUser, RoleName, Result
| sort by TimeGenerated descLine-by-line explanation
| where OperationName == "Add member to role"The directory-audit operation written whenever a principal is added to an Entra ID role.
extend Actor = coalesce(InitiatedBy.user..., InitiatedBy.app...)InitiatedBy can be a user or an application; coalesce picks whichever is present so service-principal-driven changes are not lost.
where tostring(mp.displayName) == "Role.DisplayName"The role name lives in modifiedProperties as Role.DisplayName; trim removes the surrounding quotes the audit log stores it with.
Required tables and columns
OperationNameThe audited directory action; 'Add member to role' is a role assignment.InitiatedByDynamic object identifying the user or app that performed the change.TargetResourcesThe objects affected, including the added member and the role's modifiedProperties.ResultWhether the operation succeeded or failed.
MITRE ATT&CK mapping
Tuning and false positives
- Maintain an allow-list of your Privileged Identity Management automation and break-glass accounts to suppress expected assignments.
- Filter RoleName to the highest-privilege roles first (Global Administrator, Privileged Role Administrator, Application Administrator).
Limitations
- PIM eligible-role activations use different operations; add 'Add eligible member to role' to cover just-in-time elevation.
- Group-based role assignment (role-assignable groups) shows up as a group membership change, not this operation.
Related queries
References
Last reviewed 2026-11-18.