Enable Defender ASR Rules with PowerShell
Switch on individual attack surface reduction rules — e.g. block Office apps from creating child processes.
01Command
$ Add-MpPreference -AttackSurfaceReductionRules_Ids D4F940AB-401B-4EFC-AADC-AD5F3C50688A -AttackSurfaceReductionRules_Actions Enabled02What it does
Each ASR rule has a fixed GUID — D4F940AB… blocks Office applications from spawning child processes, a common ransomware entry point. You enable rules one at a time or in bulk, and the Actions value also supports AuditMode to log blocks without enforcing them. Review events in the Microsoft Defender event log before flipping rules from audit to enabled.
03Risk
04Undo
$ Add-MpPreference -AttackSurfaceReductionRules_Ids D4F940AB-401B-4EFC-AADC-AD5F3C50688A -AttackSurfaceReductionRules_Actions Disabled05Sources
- Enable attack surface reduction rulesEvidence: PowerShell instructions use Add-MpPreference with -AttackSurfaceReductionRules_Ids and -AttackSurfaceReductionRules_Actions, listing rule GUIDs including D4F940AB-401B-4EFC-AADC-AD5F3C50688A.
- Add-MpPreference (Defender)Evidence: Documents the AttackSurfaceReductionRules_Ids and AttackSurfaceReductionRules_Actions parameters.
Last verified: 2026-09-19 · Category: Security & Privacy
06Related solutions
Understand PowerShell's execution policy scopes and set the one that lets you run your own local scripts without gutting the security model.
Two-step command sequence that makes you the owner of a locked file tree and grants yourself full control — the standard fix for 'Access is denied' on old profiles and OS reinstall leftovers.
Built-in Windows command to compute MD5, SHA1 or SHA-256 hashes of any file.