KQL for sign-in hunting
Building blocks that the code pages and guides reuse.
Which failure codes dominate my tenant?
Section titled “Which failure codes dominate my tenant?”Start here. It shows which codes appear most, so you know which pages to read first.
SigninLogs| where TimeGenerated > ago(7d)| where ResultType != "0"| summarize Events = count(), Users = dcount(UserPrincipalName) by ResultType, ResultDescription| sort by Events descThe same for non-interactive sign-ins
Section titled “The same for non-interactive sign-ins”AADNonInteractiveUserSignInLogs| where TimeGenerated > ago(7d)| where ResultType != "0"| summarize Events = count(), Users = dcount(UserPrincipalName) by ResultType, ResultDescription| sort by Events descPoints to remember
Section titled “Points to remember”ResultTypeis a string column. WriteResultType == "50126"."0"means success. Everything else is a failure or an interrupt.- Conditional Access only runs after the first factor succeeds. Credential failures show
ConditionalAccessStatusasnotApplied.