🔒 Guided

Pre-launch preview. Authorised access only.

Incorrect code

Guided by A Guide to Cloud
Explore AB-900 AI-901
Guided SC-200 Domain 1
Domain 1 — Module 9 of 12 75%
9 of 28 overall

SC-200 Study Guide

Domain 1: Manage a Security Operations Environment

  • Sentinel Workspace: Roles & Retention
  • Get Windows Events Into Sentinel
  • Syslog, CEF & Azure Data Ingestion
  • Defender for Endpoint: Core Setup
  • Attack Surface Reduction & Security Policies
  • Defender XDR: Tune Your Alerts
  • Automated Investigation & Attack Disruption
  • Sentinel Automation: Rules & Playbooks
  • Custom Detections in Defender XDR
  • Sentinel Analytics & Threat Intelligence
  • MITRE ATT&CK & Anomaly Detection
  • Detection Engineering: Putting It All Together

Domain 2: Respond to Security Incidents

  • Incident Triage: From Alert to Verdict Free
  • Purview & Defender for Cloud Threats
  • Identity Threats: Entra & Defender for Identity
  • Cloud App Security: Investigate Shadow IT
  • Sentinel Incident Response
  • Copilot for Security: Your AI Analyst
  • Complex Attacks & Lateral Movement
  • Endpoint: Timeline & Live Response
  • Endpoint: Evidence & Entity Investigation
  • M365 Investigations: Audit, Search & Graph

Domain 3: Perform Threat Hunting

  • KQL Foundations for Threat Hunters Free
  • Advanced Hunting in Defender XDR Free
  • Sentinel Hunting: Build & Monitor Queries
  • Threat Analytics & Hunting Graphs
  • Data Lake: KQL Jobs & Summary Rules
  • Notebooks & the Sentinel MCP Server

SC-200 Study Guide

Domain 1: Manage a Security Operations Environment

  • Sentinel Workspace: Roles & Retention
  • Get Windows Events Into Sentinel
  • Syslog, CEF & Azure Data Ingestion
  • Defender for Endpoint: Core Setup
  • Attack Surface Reduction & Security Policies
  • Defender XDR: Tune Your Alerts
  • Automated Investigation & Attack Disruption
  • Sentinel Automation: Rules & Playbooks
  • Custom Detections in Defender XDR
  • Sentinel Analytics & Threat Intelligence
  • MITRE ATT&CK & Anomaly Detection
  • Detection Engineering: Putting It All Together

Domain 2: Respond to Security Incidents

  • Incident Triage: From Alert to Verdict Free
  • Purview & Defender for Cloud Threats
  • Identity Threats: Entra & Defender for Identity
  • Cloud App Security: Investigate Shadow IT
  • Sentinel Incident Response
  • Copilot for Security: Your AI Analyst
  • Complex Attacks & Lateral Movement
  • Endpoint: Timeline & Live Response
  • Endpoint: Evidence & Entity Investigation
  • M365 Investigations: Audit, Search & Graph

Domain 3: Perform Threat Hunting

  • KQL Foundations for Threat Hunters Free
  • Advanced Hunting in Defender XDR Free
  • Sentinel Hunting: Build & Monitor Queries
  • Threat Analytics & Hunting Graphs
  • Data Lake: KQL Jobs & Summary Rules
  • Notebooks & the Sentinel MCP Server
Domain 1: Manage a Security Operations Environment Premium ⏱ ~11 min read

Custom Detections in Defender XDR

Turn your best hunting queries into always-on detections. Learn how to create and manage custom detection rules using Advanced Hunting in Microsoft Defender XDR.

What are custom detection rules?

☕ Simple explanation

Think of a security guard doing rounds. Every night they walk the building checking the same things — doors locked, cameras recording, alarm panels green. They are running the same checklist on a schedule.

Custom detection rules are that scheduled checklist, but for your data. You write a KQL hunting query that finds something suspicious — say, “PowerShell downloading files from unknown domains at 3 AM.” Then you save it as a custom detection rule that runs automatically every hour, every day, or every 24 hours.

When the query finds results, Defender XDR creates an alert and an incident. No analyst needs to manually run the query — it runs itself, forever.

Custom detection rules in Microsoft Defender XDR are KQL-based scheduled queries that run in the Advanced Hunting engine. When a query returns results, Defender automatically creates alerts and optionally groups them into incidents. They extend Defender XDR’s built-in detection capabilities with organisation-specific threat logic.

Custom detections operate across all Defender XDR data tables — DeviceEvents, DeviceProcessEvents, DeviceNetworkEvents, EmailEvents, IdentityLogonEvents, CloudAppEvents, and more. This cross-workload visibility is a key advantage over product-specific detections.

They differ from Sentinel analytics rules in that they run inside Defender XDR’s engine and operate on Defender data tables, whereas Sentinel analytics run in the Sentinel workspace on ingested log data.

Creating a custom detection rule

Step 1: Write the hunting query

Start in Advanced Hunting and write a KQL query that identifies the threat:

DeviceProcessEvents
| where Timestamp > ago(1h)
| where FileName == "powershell.exe"
| where ProcessCommandLine has_any ("Invoke-WebRequest", "wget", "curl")
| where ProcessCommandLine has_any (".exe", ".dll", ".ps1", ".bat")
| where InitiatingProcessFileName != "sccm.exe"  // Exclude known-good
| project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessFileName

This query finds PowerShell commands downloading executables — a common malware delivery technique.

Step 2: Save as detection rule

When your query works, click Create detection rule and configure:

SettingWhat to Configure
NameDescriptive name (e.g., “PowerShell downloading executables from unknown sources”)
FrequencyHow often the query runs: Every hour, Every 3 hours, Every 12 hours, Every 24 hours
Alert titleWhat analysts see in the alert queue
SeverityInformational, Low, Medium, High
CategoryMITRE ATT&CK tactic (Execution, Initial Access, etc.)
DescriptionWhat the detection finds and why it matters
Entity mappingMap query columns to entities: Device, User, File, IP, URL
ActionsWhat happens when the detection fires (isolate device, collect investigation package, etc.)

Step 3: Map entities

Entity mapping is critical — it tells Defender XDR which columns in your query represent which entities. This enables:

  • Automatic incident correlation (alerts sharing entities get grouped)
  • Entity pages (clicking a device name shows its full timeline)
  • Automated investigation on the mapped entities
💡 Exam tip: entity mapping is required

A custom detection rule without entity mapping still creates alerts, but those alerts cannot be correlated into incidents and cannot trigger automated investigation on specific entities.

If an exam question asks “why are custom detection alerts not being grouped into incidents?” — check if entity mapping is configured.

Managing custom detections

Frequency considerations

FrequencyBest ForLookback
Every hourTime-sensitive threats (active attacks, C2 beaconing)Query should use ago(1h)
Every 3 hoursModerate urgency (suspicious sign-ins, data exfiltration patterns)Query should use ago(3h)
Every 12 hoursLow urgency, high volume (policy violations, shadow IT)Query should use ago(12h)
Every 24 hoursCompliance checks, trend analysisQuery should use ago(24h)

Detection rule actions

Custom detections can take automated response actions when they fire:

ActionWhat It Does
Isolate deviceCuts network access (keeps Defender connection)
Collect investigation packageGathers forensic data from the device
Run antivirus scanTriggers a full Defender Antivirus scan
Restrict app executionBlocks non-Microsoft-signed apps from running
Initiate investigationStarts an automated investigation on the entity
💡 Scenario: Tyler's custom detection for CipherStack

Tyler at CipherStack writes a custom detection for a developer credential theft technique he discovered during threat hunting:

Query: Find processes reading SSH private keys from .ssh directories on developer machines

DeviceFileEvents
| where Timestamp > ago(1h)
| where FolderPath has ".ssh"
| where FileName in ("id_rsa", "id_ed25519", "config")
| where ActionType == "FileRead"
| where InitiatingProcessFileName !in ("ssh.exe", "git.exe", "code.exe")
| project Timestamp, DeviceName, AccountName, FolderPath, InitiatingProcessFileName

Configuration:

  • Frequency: Every hour
  • Severity: High
  • Category: Credential Access (MITRE T1552)
  • Entity mapping: DeviceName → Device, AccountName → User
  • Action: Collect investigation package

Tyler’s query caught a legitimate threat two weeks later — an attacker tool reading SSH keys from a compromised developer workstation.

Custom detections work on Defender data; Sentinel analytics work on all workspace data
FeatureCustom Detections (Defender XDR)Analytics Rules (Sentinel)
EngineDefender XDR Advanced HuntingSentinel Log Analytics
Data sourceDefender tables (Device, Email, Identity, CloudApp)Any data in the Sentinel workspace
Query languageKQLKQL
Response actionsIsolate device, collect package, run AV, restrict appsRun playbook, assign, tag, close incident
Entity mappingDevice, User, File, IP, URL, MailboxAccount, Host, IP, URL, File, and more
Best forEndpoint, email, identity, and cloud app threatsCross-source detection including third-party and custom logs
Question

What is a custom detection rule in Defender XDR?

Click or press Enter to reveal answer

Answer

A KQL hunting query saved as a scheduled detection. It runs automatically at a configured frequency (1h, 3h, 12h, 24h), and when it returns results, creates alerts and incidents. It turns one-time hunting queries into always-on detections.

Click to flip back

Question

Why is entity mapping important in custom detection rules?

Click or press Enter to reveal answer

Answer

Entity mapping connects query columns to Defender XDR entities (Device, User, File, IP). Without it, alerts cannot be correlated into incidents, entity pages won't link, and automated investigation cannot target specific entities.

Click to flip back

Question

What response actions can a custom detection rule take automatically?

Click or press Enter to reveal answer

Answer

Isolate device, collect investigation package, run antivirus scan, restrict app execution, and initiate automated investigation. These actions are configured in the rule and execute when the detection fires.

Click to flip back

Knowledge Check

Tyler creates a custom detection rule but notices that alerts are not being grouped into incidents with related Defender for Endpoint alerts. What is the most likely issue?

Knowledge Check

Elena at Atlas Bank wants a custom detection that runs every hour to find suspicious PowerShell activity and automatically isolates affected devices. Where does she create this?

🎬 Video coming soon

Next up: Defender XDR detections are running. Now let’s build the other half — Sentinel analytics rules that detect threats across your entire data estate.

← Previous

Sentinel Automation: Rules & Playbooks

Next →

Sentinel Analytics & Threat Intelligence

Guided

I learn, I simplify, I share.

A Guide to Cloud YouTube Feedback

© 2026 Sutheesh. All rights reserved.

Guided is an independent study resource and is not affiliated with, endorsed by, or officially connected to Microsoft. Microsoft, Azure, and related trademarks are property of Microsoft Corporation. Always verify information against Microsoft Learn.