User Deleted From Entra
Query
AuditLogs
| where TimeGenerated > ago(90d)
| where OperationName == "Delete user"
| where Result == "success"
| extend TargetId = tostring(TargetResources[0].id)
| extend Target = substring(tostring(TargetResources[0].userPrincipalName),32)//replace_string(tostring(TargetResources[0].userPrincipalName),TargetId,'')
| extend DisplayName = tostring(TargetResources[0].userPrincipalName)
| extend Initiator =iff(isempty(parse_json(tostring(InitiatedBy.user)).userPrincipalName),parse_json(tostring(InitiatedBy.app)).displayName,(parse_json(tostring(InitiatedBy.user)).userPrincipalName))
| extend IPAddress= parse_json(tostring(InitiatedBy.user)).ipAddressExplanation
This KQL (Kusto Query Language) query is designed to analyze audit logs and extract specific information about successful user deletion operations within the last 90 days. Here's a simplified breakdown of what the query does:
-
Data Source: It starts by looking at the
AuditLogstable. -
Time Filter: It filters the logs to include only those generated in the last 90 days.
-
Operation Filter: It further filters the logs to include only entries where the operation performed was "Delete user."
-
Result Filter: It ensures that only successful deletion operations are considered by checking if the result is "success."
-
Extract Target Information:
- It extracts the
TargetIdfrom the first resource in theTargetResourcesarray. - It extracts and processes the
Targetby taking a substring of theuserPrincipalNamefrom the first resource, starting from the 32nd character. - It also extracts the
DisplayNamefrom theuserPrincipalNameof the first resource.
- It extracts the
-
Extract Initiator Information:
- It determines the
Initiatorof the deletion operation. If theuserPrincipalNameis empty, it uses thedisplayNamefrom theappinformation; otherwise, it uses theuserPrincipalName. - It extracts the
IPAddressof the initiator from theuserinformation.
- It determines the
Overall, this query is used to identify and summarize details about successful user deletions, including who was deleted, who initiated the deletion, and from which IP address the operation was performed.
Details

Jay Kerai
Released: December 2, 2025
Tables
Keywords
Operators