INVESTIGATE / QUERY LIBRARY

Start with evidence.
Validate the logic.

Twelve inspection and hunting examples with explicit prerequisites and limitations.

Examples for tenant validation. These are original starting points, not production-certified detection rules. The field names have been reviewed against the linked documentation. Validate queries in your own tenant before use.

Before you run an example

  1. Choose the named execution environment and verify the required source table or command is available.
  2. Set the tenant and investigation window. Replace sample identifiers only in your authorized environment.
  3. Inspect a raw record and verify field types, operation names and relevant collection coverage.
  4. Test benign and expected-match cases, document missing data and tune thresholds against the intended population.
  5. Before scheduling an alert, add ownership, scheduling, deduplication, incident routing and a response procedure.

Queries are read-only examples. Their results can contain sensitive identity or resource information; handle exports through the organization’s investigation process. Empty results and execution errors have different meanings and must remain distinguishable.

Q01 / Microsoft Sentinel / Log Analytics

Multi-account invalid-password activity

Find interactive invalid-password activity concentrated by source IP and time bucket.

Requires: SigninLogs populated for the tenant. This query does not include a separate non-interactive sign-in table or an external identity provider.

Microsoft Sentinel / Log Analytics
// Illustrative thresholds: tune to your environment.
SigninLogs
| where TimeGenerated > ago(1d)
| where ResultType == "50126"
| summarize Attempts=count(),
    DistinctUsers=dcount(UserPrincipalName),
    ExampleUsers=make_set(UserPrincipalName, 8)
    by IPAddress, bin(TimeGenerated, 15m)
| where DistinctUsers >= 10 and Attempts >= 20
| order by DistinctUsers desc

Interpret the result

A candidate pattern for investigation, not proof of successful compromise. Shared IPs can aggregate unrelated users. Distributed or slow attacks may remain below these illustrative thresholds.

Validate before operational use

Use a synthetic fixture or a small authorized lab exercise to verify grouping. Confirm a benign shared-proxy case and investigate successful sign-ins separately. Do not generate password sprays against production accounts.

Schema and implementation references: [9] [6]

Q02 / Microsoft Sentinel / Log Analytics

Device-code sign-ins

Review observed device-code use and the associated access decisions.

Requires: SigninLogs with AuthenticationProtocol populated. Confirm the values present in the tenant; other authentication sources may use different schemas.

Microsoft Sentinel / Log Analytics
SigninLogs
| where TimeGenerated > ago(7d)
| where AuthenticationProtocol =~ "deviceCode"
| project TimeGenerated, UserPrincipalName, UserId,
    AppDisplayName, AppId, ResourceDisplayName,
    IPAddress, ResultType, ConditionalAccessStatus,
    CorrelationId
| order by TimeGenerated desc

Interpret the result

These are flow-use records. Correlate with an approved device or application and user intent; the query does not establish phishing or capture every later action in a refreshed session.

Validate before operational use

Use an approved test application in a test tenant and compare the event with the portal details. Exercise the relevant report-only or enforced policy separately.

Schema and implementation references: [47] [6]

Q03 / Microsoft Sentinel / Log Analytics

Identity-policy and method-change review

Provide a broad audit review for Conditional Access, authentication-method and related policy changes.

Requires: AuditLogs collected. Text matching intentionally favors discovery; validate operation names against the tenant’s raw events and the current activity reference.

Microsoft Sentinel / Log Analytics
AuditLogs
| where TimeGenerated > ago(7d)
| where ActivityDisplayName contains "conditional access"
    or ActivityDisplayName contains "authentication method"
    or ActivityDisplayName contains "security info"
    or ActivityDisplayName contains "temporary access"
| project TimeGenerated, ActivityDisplayName, Category,
    Result, InitiatedBy, TargetResources, CorrelationId
| order by TimeGenerated desc

Interpret the result

A review shortlist, not a complete detection rule. Text filters can miss differently named activities. Group membership changes and workload policies need their own coverage.

Validate before operational use

Create a harmless approved change on a test object and confirm its exact operation and modified properties. Add observed variants to a versioned rule and retain the raw record.

Schema and implementation references: [7] [50]

Q04 / Microsoft Sentinel / Log Analytics

Privilege and group-change review

Inspect directory role and group changes during a defined incident window.

Requires: AuditLogs populated; the result includes routine group administration. Enrich with the organization’s privileged-group and emergency-account inventory.

Microsoft Sentinel / Log Analytics
AuditLogs
| where TimeGenerated > ago(1d)
| where Category in ("RoleManagement", "GroupManagement")
| project TimeGenerated, ActivityDisplayName, Result,
    InitiatedBy, TargetResources, CorrelationId
| order by TimeGenerated desc

Interpret the result

Broad discovery of possible changes to privilege paths. It does not calculate effective permissions or prove that a group is privileged. PIM and workload-role evidence may require additional sources.

Validate before operational use

Verify a direct test assignment and a privileged-group membership change in a test environment. Ensure the target and actor are extracted correctly before building alerts.

Schema and implementation references: [7] [17]

Q05 / Microsoft Sentinel / Log Analytics

Application-management audit review

Inspect application, ownership, credential and permission-related administration.

Requires: AuditLogs with ApplicationManagement events. Review current application objects and grants as well as historical events.

Microsoft Sentinel / Log Analytics
AuditLogs
| where TimeGenerated > ago(7d)
| where Category == "ApplicationManagement"
| project TimeGenerated, ActivityDisplayName, Result,
    InitiatedBy, TargetResources, AdditionalDetails,
    CorrelationId
| order by TimeGenerated desc

Interpret the result

A broad administrative timeline. Parse the event’s target and modified properties before classifying a credential, consent or owner change; not every event in this category is suspicious.

Validate before operational use

Use an approved test application to verify an owner or credential rotation event, then correlate its service-principal ID with workload sign-in records. Do not expose secret values.

Schema and implementation references: [7] [50] [20]

Q06 / Microsoft Sentinel / Log Analytics

Mailbox rule and delegation changes

Find selected Exchange operations associated with forwarding, inbox rules and delegation.

Requires: OfficeActivity populated through an appropriate Microsoft 365 connector. Confirm these operations are actually included in the collection.

Microsoft Sentinel / Log Analytics
OfficeActivity
| where TimeGenerated > ago(7d)
| where OfficeWorkload == "Exchange"
| where Operation in (
    "New-InboxRule", "Set-InboxRule", "UpdateInboxRules",
    "Set-Mailbox", "Add-MailboxPermission",
    "Add-RecipientPermission")
| project TimeGenerated, Operation, UserId, ClientIP,
    OfficeObjectId, Parameters, ResultStatus
| order by TimeGenerated desc

Interpret the result

Set-Mailbox covers many benign changes. Inspect Parameters and the source record for the actual property changed. A current-state inspection is still required, especially for older persistence.

Validate before operational use

Create and remove a benign rule on a designated test mailbox. Confirm the event, actor and destination are represented and document any connector gap.

Schema and implementation references: [8] [53] [32]

Q07 / Microsoft Sentinel / Log Analytics

Concentrated file downloads

Find download or full-sync activity involving many distinct file identifiers.

Requires: OfficeActivity with SharePoint and OneDrive file events. Distinct counts are approximate, and the example is not a data-volume calculation.

Microsoft Sentinel / Log Analytics
// 100 distinct objects/hour is an example, not a standard.
OfficeActivity
| where TimeGenerated > ago(1d)
| where OfficeWorkload in ("SharePoint", "OneDrive")
| where Operation in ("FileDownloaded", "FileSyncDownloadedFull")
| summarize Events=count(),
    DistinctObjects=dcount(OfficeObjectId)
    by UserId, ClientIP, bin(TimeGenerated, 1h)
| where DistinctObjects >= 100
| order by DistinctObjects desc

Interpret the result

Investigate context, file sensitivity and approved automation. Some APIs, app-only access patterns or slow collection may not appear as this pattern. No result does not rule out data theft.

Validate before operational use

Validate against synthetic fixtures and an approved sync activity sample. Tune by user population and site sensitivity; document exactly which sources and operations are covered.

Schema and implementation references: [8] [30]

Q08 / Microsoft Sentinel / Log Analytics

Sharing activity review

Review selected link-creation, link-use and sharing operations.

Requires: OfficeActivity includes the required SharePoint or OneDrive records. Verify the current operation names in source audit data.

Microsoft Sentinel / Log Analytics
OfficeActivity
| where TimeGenerated > ago(7d)
| where Operation in (
    "AnonymousLinkCreated", "AnonymousLinkUsed",
    "SharingSet", "SharingInvitationCreated")
| project TimeGenerated, OfficeWorkload, Operation,
    UserId, ClientIP, OfficeObjectId
| order by TimeGenerated desc

Interpret the result

This is a selected event set, not an effective-permission report. Read the source event to identify recipients and link scope. Anonymous use may not establish an individual identity.

Validate before operational use

Create a harmless sharing event in a test site and confirm the target and link type. Test revocation separately and document which event variants require additional rules.

Schema and implementation references: [8] [36] [30]

Q09 / Microsoft Sentinel / Log Analytics

Latest observed events by source

Inspect recency and recent volume for three expected tables.

Requires: All three named tables must exist. A missing table causes an error; that must be resolved as a collection issue, not converted into a clean result.

Microsoft Sentinel / Log Analytics
union withsource=SourceTable SigninLogs, AuditLogs, OfficeActivity
| where TimeGenerated > ago(7d)
| summarize LastObservedEvent=max(TimeGenerated),
    EventsLastHour=countif(TimeGenerated > ago(1h)),
    EventsInWindow=count()
    by SourceTable
| order by SourceTable asc

Interpret the result

A source with no rows in the seven-day window will not appear. Compare the output with an explicit expected-source inventory. Event time is not ingestion time, and a quiet tenant may legitimately have sparse activity.

Validate before operational use

Use a known benign event to verify end-to-end arrival. Test the missing-row condition against the inventory and separately measure ingestion delay and connector errors.

Schema and implementation references: [6] [7] [8]

Q10 / Microsoft Sentinel / Log Analytics

Service-principal sign-in review

Identify which applications, resources and source IPs appear in workload sign-in history.

Requires: AADServicePrincipalSignInLogs collected. Managed identities may use a separate log category and need separate coverage.

Microsoft Sentinel / Log Analytics
AADServicePrincipalSignInLogs
| where TimeGenerated > ago(7d)
| project TimeGenerated, ServicePrincipalName,
    ServicePrincipalId, AppId, ResourceDisplayName,
    IPAddress, ResultType
| order by TimeGenerated desc

Interpret the result

Sign-in history is not a complete API-operation ledger. Compare with application audit changes, resource logs and the owner’s approved infrastructure.

Validate before operational use

Run an authorized test integration and reconcile its stable identifiers and target resource. Check retention and the scope of each enabled workload sign-in category.

Schema and implementation references: [54] [21]

Q11 / Microsoft Defender XDR advanced hunting

Cloud activity for an investigated account

Collect activity associated with one Entra account object ID for workload triage.

Requires: CloudAppEvents populated through licensed and configured Defender for Cloud Apps capabilities. Replace the sample object ID. This schema uses Timestamp, not TimeGenerated.

Microsoft Defender XDR advanced hunting
let InvestigatedAccount = "00000000-0000-0000-0000-000000000000";
CloudAppEvents
| where Timestamp > ago(7d)
| where AccountObjectId == InvestigatedAccount
| project Timestamp, Application, ActionType,
    AccountObjectId, AccountDisplayName, IPAddress,
    RawEventData
| order by Timestamp desc

Interpret the result

Only activity represented in this table is returned. The schema and source coverage differ from Sentinel OfficeActivity; queries are not interchangeable solely because both use KQL.

Validate before operational use

Compare a known harmless action with its source audit record and verify account resolution. Confirm that the services under investigation actually populate the table.

Schema and implementation references: [55]

Q12 / Exchange Online PowerShell

Read-only mailbox and audit inspection

Inspect current forwarding, rule, delegate and organization audit settings.

Requires: An authenticated Exchange Online PowerShell session with RBAC permissions for these read commands. Replace the example mailbox. Run the audit-status command in Exchange Online, not only Security & Compliance PowerShell.

Exchange Online PowerShell
$Mailbox = "review-mailbox@example.invalid"

Get-Mailbox -Identity $Mailbox |
  Select-Object ForwardingAddress, ForwardingSmtpAddress,
    DeliverToMailboxAndForward, GrantSendOnBehalfTo

Get-InboxRule -Mailbox $Mailbox -IncludeHidden |
  Select-Object Identity, Name, Enabled,
    ForwardTo, RedirectTo, ForwardAsAttachmentTo,
    DeleteMessage, MoveToFolder

Get-MailboxPermission -Identity $Mailbox |
  Select-Object User, AccessRights, IsInherited, Deny

Get-RecipientPermission -Identity $Mailbox |
  Select-Object Trustee, AccessRights

Get-AdminAuditLogConfig |
  Select-Object UnifiedAuditLogIngestionEnabled

Get-OrganizationConfig |
  Select-Object AuditDisabled

Interpret the result

These commands inspect current configuration and do not establish when a setting changed or whether mail was disclosed. Transport rules, app-only access and mailbox-specific audit exceptions require further inspection.

Validate before operational use

Compare the results with a known test mailbox and the corresponding administration view. Record errors and missing permissions. A failed command is not a passed check.

Schema and implementation references: [53] [32] [41] [28]