DEFENDER
SET-MPPREFERENCE
EXCLUSIONS
TAMPER PROTECTION
DetectionBlue TeamSOCOctober 12, 2026•9 min read

Detecting Defender Tampering: Set-MpPreference, Exclusions and Services

Before encryption, deployment or credential theft, many operators try to turn Defender off. They fail more often than they succeed, and the attempts are the alert.

Scroll

Ransomware affiliates and commodity malware routinely try to disable Microsoft Defender with Set-MpPreference, registry edits, service stops or by adding blanket exclusions. Tamper protection blocks much of this when enabled, but the blocked attempts and the successful ones both generate telemetry. Coverage here is among the highest-value, lowest-noise detections you can run.

Signals at a Glance

SignalWhereATT&CK
Set-MpPreference with DisableRealtimeMonitoring, DisableBehaviorMonitoring or DisableIOAVProtectionPowerShell 4104, Sysmon 1T1562.001
Add-MpPreference -ExclusionPath, -ExclusionProcess or -ExclusionExtensionPowerShell 4104, Defender 5007T1562.001
Real-time protection disabled (Defender Event 5001)Defender OperationalT1562.001
sc stop WinDefend, sc config, or DisableAntiSpyware set in the registrySysmon 1, 13T1562.001
Tamper protection blocked an attemptMDE TamperingAttempt alertsT1562.001

Command-Line and Event Detections

Start with the commands, because they appear in nearly every intrusion that bothers to try. Defender also logs the result: Event 5001 when real-time protection is turned off and 5007 whenever its configuration changes, including added exclusions.

// Microsoft Defender XDR (KQL) - Defender tampering commands and blocked attempts
let cmds = DeviceProcessEvents
| where ProcessCommandLine has_any ("Set-MpPreference", "Add-MpPreference")
| where ProcessCommandLine has_any ("DisableRealtimeMonitoring", "DisableBehaviorMonitoring",
        "DisableIOAVProtection", "DisableScriptScanning", "ExclusionPath",
        "ExclusionProcess", "ExclusionExtension", "MAPSReporting 0", "SubmitSamplesConsent 2")
   or ProcessCommandLine has_all ("sc", "stop", "WinDefend")
   or ProcessCommandLine has_all ("reg", "DisableAntiSpyware")
| project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessFileName;
let blocked = DeviceEvents
| where ActionType == "TamperingAttempt"
| project Timestamp, DeviceName, AdditionalFields, InitiatingProcessFileName;
cmds
| union blocked
| order by Timestamp desc
// tune/validate: confirm TamperingAttempt is exposed in your tenant.

For hosts without Defender for Endpoint telemetry, the Defender Operational log still carries the evidence. Alert on the change events and review who or what made them:

index=wineventlog source="WinEventLog:Microsoft-Windows-Windows Defender/Operational"
  (EventCode=5001 OR EventCode=5007 OR EventCode=5010 OR EventCode=5012)
| eval change=case(EventCode=5001,"realtime_disabled",
                   EventCode=5007,"config_changed",
                   EventCode=5010,"scan_disabled",
                   EventCode=5012,"antivirus_scan_disabled")
| rex field=Message "New value:\s*(?<new_value>.+)"
| where change!="config_changed" OR like(new_value,"%Exclusions%")
| stats count min(_time) as first by host, change, new_value
`comment("tune/validate: allow expected exclusions pushed by your management platform")`

Hardening and Triage

Vetted sources

Use the SigmaHQ Defender tampering and exclusion rules, Elastic’s defense-evasion detections for Defender, Splunk ESCU content on Set-MpPreference, Microsoft’s tamper protection documentation and Atomic Red Team T1562.001 tests. Baseline your own environment — deployment tooling and security software legitimately add exclusions.

Build Detections That Fire

Mjolnir Security helps blue teams turn threat intelligence into high-fidelity detections across endpoint, network, identity and cloud telemetry.

Detection EngineeringManaged Detection & ResponseThreat HuntingIncident ResponsePurple Teaming
  • Detection Engineering We build and tune detections mapped to ATT&CK from your own telemetry.
  • Threat Hunting as a Service Hypothesis-driven hunts for the behaviours on this page.
  • 24/7 Incident Response Containment when a detection fires. Call +1 833 403 5875.
Written by: Mjolnir Threat Research (MTAC)  |  Published: October 12, 2026  |  Last reviewed: October 12, 2026