FIELD GUIDE / 01

Audit first.
Then enforce.

Everything you need to take a policy from the builder to a Windows device safely, and back again if you need to.

01 / REQUIREMENTS

What the device needs.

Windows

Windows 10 or 11 (Pro, Enterprise, Education) or Windows Server 2012 R2 and later with the modern unified Defender client. Some rules need newer builds; see each rule's minimum OS in the rule reference.

Defender Antivirus, active

ASR rules require Microsoft Defender Antivirus as the active antivirus. In passive mode (another AV is primary) rules don't enforce; the script warns. Several rules also need cloud-delivered protection.

PowerShell

Windows PowerShell 5.1 or PowerShell 7. The script uses Set-StrictMode -Version Latest, never calls Invoke-Expression on input and downloads nothing else.

Permissions

Install and Restore need an elevated session. Save and Status don't. Collect needs read access to the Defender Operational event log.

02 / ROLLOUT PLAN

A rollout that won't page you.

  1. Build an audit policy.

    Start from a preset in the builder and set the rules you're considering to Audit.

  2. Install on a pilot ring.

    Run Install (or the Intune/GPO export) on a representative set of devices.

  3. Collect and analyze.

    After one to four weeks, run Collect and load the CSVs into Event analysis.

  4. Block the quiet rules, tune the noisy ones.

    Rules with no audit hits are block candidates. For the rest, add narrow exclusions or keep them in Warn.

  5. Widen gradually.

    Expand ring by ring, keeping the backup and Restore path ready. Microsoft's ASR deployment guide covers the same phases.

03 / SCRIPT ACTIONS

One script, six actions.

Each command below uses the same loader. In the builder, the policy string is filled in for you.

Save · No admin

Decodes and validates the policy, then writes <slug>.asr-policy.json and <slug>.install.ps1, a standalone offline script that applies this exact policy with Set/Add-MpPreference. Use it for review, change records or air-gapped machines.

PowerShell · Save
& ([scriptblock]::Create((irm 'https://asrrules.com/asr-rules-builder.ps1'))) -Policy '<your policy>' -Action Save
# files land in $env:USERPROFILE\ASR-Rules-Builder (change with -OutDir)
Install · Administrator

Checks Windows, elevation and the Defender cmdlets; warns about GPO/MDM management and passive mode; prints current → new for every rule; asks “Are you sure you want to install this ASR policy? [y/N]”; writes a backup; applies; re-reads and verifies. Exit codes: 0 ok, 1 validation, 2 environment, 3 verify mismatch, 4 cancelled, 5 applied with omissions (see the exit code table below).

PowerShell · Install
& ([scriptblock]::Create((irm 'https://asrrules.com/asr-rules-builder.ps1'))) -Policy '<your policy>' -Action Install
Install -WhatIf · Administrator

Shows the same plan as Install and stops. Nothing changes and no backup is written.

PowerShell · Install -WhatIf
& ([scriptblock]::Create((irm 'https://asrrules.com/asr-rules-builder.ps1'))) -Policy '<your policy>' -Action Install -WhatIf
Status · No admin

Prints every configured ASR rule with its name, GUID and mode, the ASR-only exclusions, and whether Group Policy or MDM manages ASR on this device.

PowerShell · Status
& ([scriptblock]::Create((irm 'https://asrrules.com/asr-rules-builder.ps1'))) -Action Status
Collect · Event log read

Reads events 1121, 1122, 1129, ASR-related 5007, and CFA/network protection 1123–1126 for the last -Days (1–365, default 30), writes a CSV and prints an analysis. Drop the CSV into Event analysis for charts.

PowerShell · Collect
& ([scriptblock]::Create((irm 'https://asrrules.com/asr-rules-builder.ps1'))) -Action Collect -Days 30
Restore · Administrator

Shows the newest backup (or the one in -BackupPath), asks “Are you sure you want to restore this ASR backup? [y/N]”, then reapplies it.

PowerShell · Restore
& ([scriptblock]::Create((irm 'https://asrrules.com/asr-rules-builder.ps1'))) -Action Restore
# or a specific backup:
& ([scriptblock]::Create((irm 'https://asrrules.com/asr-rules-builder.ps1'))) -Action Restore -BackupPath "$env:ProgramData\ASR-Rules-Builder\backups\asr-backup-20261202-101500.json"
ParameterNotes
-ActionSave (default), Install, Status, Collect, Restore
-PolicyEncoded policy from the builder. Required for Save and Install.
-OutDirOutput folder for Save and Collect. Default $env:USERPROFILE\ASR-Rules-Builder.
-DaysCollect lookback, 1–365, default 30.
-ForceSkip the Install/Restore confirmation prompt (fleet tools).
-BackupPathRestore source. Default: newest trusted file in $env:ProgramData\ASR-Rules-Builder\backups. Only backups owned by Administrators or SYSTEM, in a folder non-admins can't write to, are restored.
-WhatIfInstall/Restore: show the plan, change nothing. Save/Collect: print the files that would be written, write nothing.

04 / VERIFY THE SCRIPT

Inspect before you run.

Prefer not to pipe a download into PowerShell? Download it, read it, compare the hash, then run it from disk.

PowerShell · inspect-first
irm 'https://asrrules.com/asr-rules-builder.ps1' -OutFile .\asr-rules-builder.ps1
notepad .\asr-rules-builder.ps1
(Get-FileHash .\asr-rules-builder.ps1 -Algorithm SHA256).Hash -eq '9FE67A08D9EC75DC914EB06156EAF682084CFB74EDED167E239EF505CAC14E43'
.\asr-rules-builder.ps1 -Policy '<your policy>' -Action Save

SHA-256 of the script published with this build: 9FE67A08D9EC75DC914EB06156EAF682084CFB74EDED167E239EF505CAC14E43

05 / INTUNE & RMM

Unattended installs.

Fleet tools can't answer prompts. Add -Force to skip the confirmation; everything else (validation, backup, verification, exit codes) still happens. For managed fleets, the native Intune and Group Policy exports in the builder are usually a better fit.

PowerShell · SYSTEM context
# Intune remediation, Intune platform script or RMM job (runs as SYSTEM, no prompt):
& ([scriptblock]::Create((irm 'https://asrrules.com/asr-rules-builder.ps1'))) -Policy '<your policy>' -Action Install -Force
exit $LASTEXITCODE
cmd / RMM · one command line
# RMM that runs a single command line (powershell.exe -Command): end with exit $LASTEXITCODE,
# otherwise the process exit code is 0 even when the install failed.
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& ([scriptblock]::Create((irm 'https://asrrules.com/asr-rules-builder.ps1'))) -Policy '<your policy>' -Action Install -Force; exit $LASTEXITCODE"

Exit codes for your RMM

CodeMeaning
0Success: installed and verified (or -WhatIf finished).
1Validation: the policy or the backup was rejected (invalid, missing, or an untrusted backup file).
2Environment: not Windows, not elevated, Defender cmdlets missing, event log not readable, a file could not be written, or the backup folder is unsafe (a link, or owned by a non-administrator).
3An apply error or a verification mismatch after Install or Restore.
4Cancelled at the prompt, or no interactive console to ask. Add -Force.
5Installed and verified, but part of the policy could not be applied on this device (for example per-rule exclusions on a Defender build without them). Use Intune or Group Policy for those.

The [scriptblock]::Create((irm …)) one-liner leaves the code in $LASTEXITCODE instead of closing your window. A script body must end with exit $LASTEXITCODE; a powershell.exe -Command "…" line must end with ; exit $LASTEXITCODE.

05B / PUSH TO INTUNE

Create the Intune policy for you.

tools/intune/Publish-AsrIntunePolicy.ps1 turns a builder policy into an Intune Endpoint security › Attack surface reduction policy through Microsoft Graph, including ASR-only and per-rule exclusions and controlled folder access. Run it from PowerShell 7 with an account that has the Endpoint Security Manager or Intune Administrator role; DeviceManagementConfiguration.ReadWrite.All needs admin consent the first time.

pwsh · admin workstation
Install-Module Microsoft.Graph.Authentication -Scope CurrentUser   # once
git clone https://github.com/magicsword-io/ASR-Rules-Builder.git; cd ASR-Rules-Builder
./tools/intune/Publish-AsrIntunePolicy.ps1 -Policy '<your policy>' -WhatIf   # preview, no sign-in
./tools/intune/Publish-AsrIntunePolicy.ps1 -Policy '<your policy>'           # create, unassigned
./tools/intune/Publish-AsrIntunePolicy.ps1 -Policy '<your policy>' -AssignGroupName 'ASR Pilot'
What to expect

It uses the Graph beta endpoint, checks every setting against your tenant before creating anything, asks [y/N], and creates the policy unassigned unless you name a group. Sign-in is interactive and nothing is stored. Network protection isn't pushed (it lives in the Antivirus profile), per-rule exclusions for the WMI persistence rule aren't supported by Intune, exclusions on rules set to Off are left out, and entries containing | are rejected. The builder's Intune tab flags all of these for your policy. Details: docs/intune.md.

06 / RESTORE & RESET

Every change has an undo.

Install writes %ProgramData%\ASR-Rules-Builder\backups\asr-backup-<yyyyMMdd-HHmmss>.json before it changes anything. -Action Restore reapplies the newest one, or the one you name with -BackupPath.

To back out a single rule or exclusion by hand, use the Defender cmdlets directly:

PowerShell · administrator
# Turn a single rule off explicitly (value 0) instead of leaving it configured:
Add-MpPreference -AttackSurfaceReductionRules_Ids <GUID> -AttackSurfaceReductionRules_Actions Disabled

# Remove a rule from local configuration entirely:
Remove-MpPreference -AttackSurfaceReductionRules_Ids <GUID>

# Remove an ASR-only exclusion:
Remove-MpPreference -AttackSurfaceReductionOnlyExclusions 'C:\Path\app.exe'

Settings applied through Intune or Group Policy must be removed there; local commands can't override them. For the .reg or Registry.pol exports, delete the values under HKLM\Software\Policies\Microsoft\Windows Defender\Windows Defender Exploit Guard.

FAQ

Questions people ask.

Will this fight my Intune or Group Policy settings?

It can't win that fight. Policy-delivered ASR settings take precedence over local Set-MpPreference changes, and the script warns when it finds them. Use the Intune or Group Policy exports instead for managed devices.

What happens to rules I didn't touch?

Nothing. Only rules in the policy are written. Choose Off to explicitly disable a rule; Not set leaves it as it is.

Why is Warn missing for some rules?

Microsoft doesn't support warn mode for every rule (for example LSASS credential theft). The builder disables it and the script rejects it.

Does the site see my policy?

No. The policy lives in the URL fragment, which browsers never send to servers. There are no analytics or runtime network calls, and the analyzer parses CSVs locally.

Can I run it without downloading code at runtime?

Yes. Use Save on any machine to produce a standalone install script, review it, and run that offline, or use the inspect-first flow to verify the hash.

Do per-rule exclusions work everywhere?

Microsoft documents per-rule exclusions for Group Policy and the Intune endpoint security ASR profile. Install applies them only when the device's Defender exposes the per-rule parameters, and warns otherwise.

SAFETY NOTES

Read before production.

Blocking breaks things

Office macros, line-of-business installers, management agents using WMI or PsExec, and backup tools are common casualties. Audit first.

Exclusions weaken rules

Exclude specific signed binaries, never drive roots, user-writable folders or script hosts. Every exclusion is a hole an attacker can aim for.

Controlled folder access

In block mode it commonly stops legitimate apps from saving documents. Audit it, review events 1124 and allow trusted apps before enforcing.

Not a Microsoft product

ASR Rules Builder is independent and provided as-is under Apache-2.0. Validate every policy in a lab before production.