MFA KQL query to detect events where a user account was created more than 90 days ago, and it works as expected when run manually. However, the query doesn’t seem to work when configured in a scheduled rule

Jatin Wadhwa 0 Reputation points
2025-04-14T06:18:53.6566667+00:00

We have written an MFA KQL query to detect events where a user account was created more than 90 days ago, and it works as expected when run manually. However, the query doesn’t seem to work when configured in a scheduled rule. Could you please help us resolve this issue?

let NewUsers = IdentityInfo     | where AccountCreationTime >= ago(90d)     | summarize LatestEntry=max(TimeGenerated) by AccountUPN     | project AccountUPN; AuditLogs | where OperationName contains "User registered"     or OperationName contains "Add passkey"     or OperationName contains "User deleted"     or OperationName contains "User changed"     or OperationName contains "User updated"  | where OperationName != "User started password reset" | where Result == "success" | where ResultDescription !contains "User started" | where ResultDescription !contains "User registered all required security info"  | where ResultDescription !contains "User registered phone method" | where isnotempty(ResultDescription) | where TimeGenerated >= ago(15m) //| where ResultDescription !contains "User registered all required security info" | extend userPrincipalName_ = tostring(parse_json(tostring(InitiatedBy.user)).userPrincipalName) | extend InitiatorUPN = tolower(tostring(InitiatedBy.user.userPrincipalName)) | extend FromIP = tostring(InitiatedBy.user.ipAddress)  | extend TargetUPN = tostring(TargetResources[0].userPrincipalName) | extend InitiatorID = tostring(InitiatedBy.user.id) | extend ResultDescription = strcat(ResultDescription, ".") | where TargetUPN !in (NewUsers)  | summarize     ModifiedAccounts = make_set(TargetUPN, 100),     Start = min(TimeGenerated),     End = max(TimeGenerated),     Actions = make_set(OperationName, 10)     by InitiatorID, InitiatorUPN, FromIP, ResultDescription, TargetUPN

Microsoft Sentinel
Microsoft Sentinel
A scalable, cloud-native solution for security information event management and security orchestration automated response. Previously known as Azure Sentinel.
1,268 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Clive Watson 7,636 Reputation points MVP
    2025-04-16T08:56:15.8566667+00:00

    Hello, Sentinel rules have a maximum lookback of 14days, so even though you put 90days that is ignored and 90 is used.

    The workaround is to run a playbook that does the 90day lookback on a schedule.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.