Enterprise and advanced workstation security strategies rely heavily on hardening the operating system against common attack vectors used by ransomware, script-based exploits, and malicious office macros. Microsoft Defender includes Attack Surface Reduction (ASR) rules designed to prevent software behaviours that are frequently weaponised. However, enforcing ASR rules directly into block mode can disrupt legitimate administrative scripts and line-of-business software. Configuring ASR rules in Audit Mode via PowerShell allows administrators to monitor potential rule triggers in the Windows Event Log without interrupting everyday user activity.
What Are Attack Surface Reduction (ASR) Rules?
ASR rules are behavioural mitigations embedded within Microsoft Defender Antivirus. Each rule targets a specific operational behaviour, such as:
- Blocking executable content from email client and webmail.
- Preventing Office applications from creating child processes or injecting code into other processes.
- Blocking obfuscated scripts and suspicious PowerShell script executions.
- Preventing credential stealing from the Windows Local Security Authority Subsystem Service (LSASS).
- Blocking untrusted and unsigned processes that run from USB drives.
Every ASR rule is identified by a unique Globally Unique Identifier (GUID) and can be configured in one of four states: Disabled (0), Block (1), Audit (2), or Warn (6).
Prerequisites and Environment Requirements
- Windows 11 Pro, Enterprise, or Education edition.
- Microsoft Defender Antivirus configured as the primary real-time protection engine.
- An elevated PowerShell console launched with local Administrator privileges.
Checking Current ASR Configuration in PowerShell
To inspect which ASR rules are currently active on your workstation, open an elevated PowerShell prompt (Run as Administrator) and query the Defender preferences:
Get-MpPreference | Select-Object -ExpandProperty AttackSurfaceReductionRules_Ids
Get-MpPreference | Select-Object -ExpandProperty AttackSurfaceReductionRules_Actions
To format the output into a readable table mapping rule GUIDs to their configured action states:
$prefs = Get-MpPreference
$ids = $prefs.AttackSurfaceReductionRules_Ids
$actions = $prefs.AttackSurfaceReductionRules_Actions
for ($i = 0; $i -lt $ids.Count; $i++) {
[PSCustomObject]@{
RuleID = $ids[$i]
Action = switch ($actions[$i]) {
0 { "Disabled" }
1 { "Block" }
2 { "Audit" }
6 { "Warn" }
Default { "Unknown" }
}
}
} | Format-Table -AutoSize
Configuring ASR Rules in Audit Mode
To configure a specific ASR rule in Audit Mode, use the Set-MpPreference cmdlet with the rule GUID and action code 2. For example, to audit the rule that blocks credential stealing from LSASS (GUID: 9e6c4e1f-7d60-472f-ba1a-a39ef669e4b2):
Set-MpPreference -AttackSurfaceReductionRules_Ids "9e6c4e1f-7d60-472f-ba1a-a39ef669e4b2" -AttackSurfaceReductionRules_Actions 2
Setting All Common ASR Rules to Audit Mode
To evaluate workstation compatibility across the standard enterprise baseline, you can set the primary ASR rules to Audit Mode simultaneously:
$ASRRules = @(
"d4f940ab-401b-4efc-aadc-ad5f3c50688a", # Block all Office applications from creating child processes
"3b576869-a4ec-4529-8536-b80a7769e899", # Block executable content from email client and webmail
"756346d7-0a4f-446a-a728-0610f6f2a571", # Block Office applications from injecting code into other processes
"9e6c4e1f-7d60-472f-ba1a-a39ef669e4b2", # Block credential stealing from LSASS
"56a863a9-875e-4185-98a7-b882c60b5ce5", # Block abuse of exploited vulnerable signed drivers
"b2b3f03d-6a65-4f7b-a9c7-1c7ef74a9ba4" # Block untrusted and unsigned processes from USB
)
$Actions = @(2) * $ASRRules.Count
Set-MpPreference -AttackSurfaceReductionRules_Ids $ASRRules -AttackSurfaceReductionRules_Actions $Actions
Reviewing ASR Audit Events in Windows Event Viewer
When an ASR rule configured in Audit Mode detects a triggering behaviour, it allows the process to execute normally while generating an audit event in the Windows Event Log under Event ID 1122 (Event ID 1121 represents an enforced block).
You can query these audit events directly from PowerShell without manually scrolling through Event Viewer:
Get-WinEvent -FilterHashtable @{
LogName = "Microsoft-Windows-Windows Defender/Operational"
Id = 1122
} -MaxEvents 20 | Select-Object TimeCreated, Message | Format-List
Each recorded event details:
- The specific ASR Rule GUID that was triggered.
- The initiating process name and full executable path.
- The target file, child process, or memory region accessed.
Configuring Exclusions for Legitimate Applications
If an essential administrative utility or development tool generates benign audit events, you can add an exclusion path before transitioning the rule into Block Mode:
Add-MpPreference -AttackSurfaceReductionOnlyExclusions "C:\Path\To\TrustedUtility.exe"
Once you have validated that no critical workflows are negatively affected, transition the rule from Audit (2) to Block (1) using Set-MpPreference.