Intune remediation scripts are paired PowerShell scripts that find a problem on a Windows device and fix it before a user calls the help desk. A detection script checks for the problem. A remediation script fixes it, but only when detection says it is needed. The scripts are easy to write. The hard part for a small company is running them safely: testing as the right account, scoping to the right devices, and keeping a record of who deployed what. This guide covers the whole routine, including the audit trail.
If you are a business owner or operations lead without a full internal IT team, treat remediations as code that runs with high privilege on every laptop you manage. That framing drives every step below. It is also where outside technology leadership pays for itself: a fractional CTO from Mindpod Technologies can set the guardrails once so your IT person or provider is not improvising them on each script.
TL;DR
- A remediation package is a detection script, a remediation script and metadata. The fix runs only if detection exits with code 1.
- Microsoft renamed Proactive Remediations to Remediations. You find them under Devices > Manage devices > Scripts and remediations.
- Licensing is the first blocker: Windows Enterprise E3/E5-level user licensing, Entra-joined or hybrid-joined devices, and Intune enrollment.
- Test as SYSTEM, pilot on a small group, and start with a slow schedule.
- Scripts are code with admin rights. Turn on audit log export, and consider Multi Admin Approval for script changes.
Table of Contents
- What Intune remediation scripts are
- What you need before the first script
- Writing a detection script that behaves
- Execution context: SYSTEM or the signed-in user
- Create, assign and schedule the package
- Monitoring results and troubleshooting
- Audit logging: who changed the scripts
- Where remediations pay off, and where to use something else
- Getting help with the rollout
- FAQ
- Sources
What Intune remediation scripts are
According to Microsoft Learn, Proactive Remediations was renamed Remediations. Searches use both names, and the screens are the same. A remediation is a script package that detects and fixes common support issues before users notice them. Each package holds a detection script, a remediation script and metadata.
The logic is simple:
- Intune runs the detection script on the schedule you set.
- If it exits with code 0, the device is healthy and nothing else happens.
- If it exits with code 1, Intune runs the remediation script.
- Detection then runs again to confirm the fix took.
Any other exit code means no remediation runs. This is the most common reason a package "finds" problems and never fixes them.
Microsoft ships a few packages ready to use, including one that detects a Group Policy refresh older than seven days and runs gpupdate. It also publishes samples for expired certificates, with configurable values such as the certificate authority and the number of days before expiry. Reading these is the quickest way to see the pattern before you write your own.
What you need before the first script
The prerequisites on Microsoft Learn are specific, and licensing is where small businesses most often get stuck.
| Requirement | What Microsoft states |
|---|---|
| Devices | Microsoft Entra joined or hybrid joined, and either enrolled in Intune (Windows Enterprise, Professional or Education) or co-managed |
| User licenses | Windows Enterprise E3/E5 (included in Microsoft 365 F3/E3/E5), Windows Education A3/A5, or Windows VDA per-user |
| Admin permissions | Device configurations role permissions |
| First use | An Intune Service Administrator must confirm licensing before the feature can be used |
Two limits matter in practice. The documented maximum is 200 script packages, and script output is capped at 2,048 characters. Scripts should be saved as UTF-8.
If your users hold Microsoft 365 Business Premium rather than the plans listed above, check your licensing before building anything. Settle it with whoever owns your Microsoft agreement. The Create button can be unavailable until licensing is verified.
Writing a detection script that behaves
A good detection script does one thing: it tests a single condition and reports the result through its exit code. A widely used pattern, shown in a tested Fast Startup example, reads one registry value and exits 1 if it is not the desired setting. The matching remediation script sets the value and exits 0 on success, or 1 in its catch block.
A skeleton looks like this:
# Detect
try {
$v = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power').HiberbootEnabled
if ($v -ne 0) { Write-Output 'Fast Startup on'; exit 1 }
Write-Output 'Compliant'; exit 0
} catch { Write-Output $_.Exception.Message; exit 0 }
Some habits keep these scripts safe:
- Keep output short and useful. What you pass to Write-Output is what shows in the Device status columns. Anything past 2,048 characters is cut off.
- Decide what an error means. In the sketch above, a script that cannot read the value exits 0, so it does not trigger a change on a device it does not understand. Make that choice on purpose.
- Make the fix idempotent. Running it twice should do no harm.
- Never hard-code secrets. The script file is stored in the tenant and readable by admins with the right role.
- Change one thing per package. A package that touches ten settings is hard to roll back and hard to read in a report.
Execution context: SYSTEM or the signed-in user
Three settings on the package control how the scripts run: run using the logged-on credentials, enforce script signature check, and run in 64-bit PowerShell. By default scripts run as SYSTEM. Anything that touches HKCU, the user's certificate store or a toast notification needs the logged-on credentials. The Microsoft sample for expired issuer certificates, for example, runs with logged-on credentials set to Yes because it notifies the user.
This is where scripts that work in your own console fail in production. Test as SYSTEM before you upload, using the Sysinternals PsExec tool with the -s -i switches, then check $LASTEXITCODE. A troubleshooting guide makes the same point: whether you need SYSTEM or 64-bit PowerShell can only be confirmed by running through the Intune Management Extension, not just locally.
Create, assign and schedule the package
The Microsoft Learn steps for a custom package are:
- Open Devices > Manage devices > Scripts and remediations and choose Create script package.
- On Basics, enter a name and description. Publisher defaults to your name.
- On Settings, upload the detection and remediation .ps1 files and set the three execution options.
- Add scope tags if you use them.
- On Assignments, pick device groups. Microsoft advises against mixing user and device groups across include and exclude.
- Choose a schedule, then Review + Create.
The schedule options are Once, Hourly (every n hours, fewer than 24) and Daily. Runs follow the device's local time unless you choose UTC, and a missed run executes as soon as the device is back online. Microsoft recommends less frequent schedules, such as every seven days, for scripts that are not urgent or are resource-heavy. A daily run of a heavy script across every laptop is a self-inflicted slowdown.
A rollout pattern that avoids surprises
- Assign first to a pilot group of three to five devices, including one that is rarely online.
- Run the package once, check results, then move it to a weekly schedule.
- Widen to a department, then to everyone.
- Keep the previous script version in a repository so you can restore it quickly.
Monitoring results and troubleshooting
In the admin center, the package overview shows devices without issues, with issues, with issues fixed and with recurring issues. A device-level view sits at Devices > All devices > select a device > Tools > Remediations, per Microsoft's what's new page. You can also trigger a package on one device with the Run remediation device action, which needs a role such as Help Desk Operator or a custom role with the Run Remediation permission.
The recurring counter is your best early warning. If the same devices keep reappearing, something else, such as a policy or an app, is changing the setting back. Fix the cause rather than raising the schedule.
Common symptoms and what to check:
| Symptom | Likely cause |
|---|---|
| Package never runs | Wrong group, Intune Management Extension missing, device not Entra joined |
| Issues found, nothing fixed | Detection exits with something other than 1, or no remediation script uploaded |
| Output cut short | More than 2,048 characters written |
| Works locally, fails in Intune | Wrong context (user vs. SYSTEM) or 32-bit vs. 64-bit PowerShell |
On the device, the log to open first is AgentExecutor.log in C:\ProgramData\Microsoft\IntuneManagementExtension\Logs. It shows the script path, the output and the exit code, as described in this troubleshooting guide. The same guide suggests adding Start-Transcript to your scripts so each run leaves a local log.
Audit logging: who changed the scripts
A remediation script runs with SYSTEM rights on many machines. Whoever can edit one can change those machines. For a company of 20 to 200 people, the question "who changed that script and when" needs an answer you can produce.
Intune audit logs record create, update, delete and assign actions, and Microsoft documents that admins cannot delete them. Review them under Tenant administration > Audit logs. Two limits are worth knowing. Audit logs capture the change to the package, not what the script did on the device. Execution evidence has to come from endpoint protection and the local logs above.
To keep records beyond the portal and alert on them, IBM X-Force describes the setup: in Tenant administration > Diagnostic settings, add a setting that sends AuditLogs and OperationalLogs to a Log Analytics workspace, where they can feed Microsoft Sentinel. The same write-up shows a Multi Admin Approval access policy for the Script profile type, so a second person must approve a new script deployment. Reviewing audit entries and approval decisions alongside document and report sharing is part of a broader set of security controls for shared documents, since your change records and runbooks are sensitive in their own right.
A small team can keep this light. Send audit logs to a workspace, set an alert for new or changed script packages, and require approval for script changes. Pair that with least-privilege roles, as in our Entra security practices for SMBs, so few accounts can edit scripts at all.

AI audit logging is a separate trail
Searches for remediation scripts increasingly sit next to AI audit log questions, because AI tools now draft scripts too. Keep the two records apart. Intune audit logs tell you who deployed a script. They do not record the prompt that produced it.
For Microsoft 365 Copilot, Microsoft Purview captures prompts and responses in the unified audit log, along with the service involved, files referenced and sensitivity labels. You search them in the Purview Audit solution. If a person or an agent drafts a remediation script with AI, the rule we apply is simple: a human reads the script, tests it as SYSTEM on a pilot device, and deploys it through the same approval path as any other change.
Where remediations pay off, and where to use something else
Remediations suit drift that is detectable on a single device: a stopped service, a stale policy refresh, a full temp folder, an expired certificate, a registry setting that keeps reverting. They are not the right tool for patching strategy or for cloud resource drift, which is handled in Azure. For that second case, see our look at Azure Policy automation failures. For application control on the endpoint itself, Windows Defender Application Control is a separate layer.
Pick a first target by counting tickets. If "disk full" or "VPN profile stale" accounts for several tickets a month, that is your pilot. Measure tickets for that issue before and after four weeks, and write down the number. That gives you a business outcome rather than a count of scripts.
Our view: governance first, scripts second
Most small companies do not fail at writing the PowerShell. They fail at the habits around it: nobody owns the script library, nobody can say who approved the last change, and the same fix quietly reruns on every device for a year.
We approach automation the way we approach AI: find where it creates leverage, rank it by return and risk, build it into the tools your team already uses, and ship with monitoring, rollback and human checkpoints from day one. A remediation package fits that model well. It is small, testable and reversible, if you treat it as production code.
Our engagements start with a free technology assessment and produce a plain-language plan you own. For Intune, that plan usually means a short list of high-ticket issues, a pilot group, an approval path and an audit log setup.
jaras
Getting help with the rollout
If you want the licensing check, pilot design and audit setup handled without hiring a full-time engineer, our Fractional CTO engagements cover technology leadership for companies your size, and our Cloud & Training service covers Azure and cloud work. The simplest start is a 30-minute call to go over your devices and your top ticket categories.

FAQ
What is the difference between Proactive Remediations and Remediations in Intune?
Nothing functional. Microsoft renamed Proactive Remediations to Remediations, and both names describe the same detection and remediation script packages. Older blog posts and search results use the old name, so the steps in them usually still apply, though menu paths have moved.
Why does my detection script find a problem but the fix never runs?
The remediation script runs only when detection exits with code 1. If your script exits 0 or any other code, no remediation runs. Also confirm that a remediation file was uploaded and that the package is assigned to the device group you are testing.
How often should a remediation run?
Microsoft offers Once, Hourly and Daily schedules and recommends less frequent runs, such as every seven days, for nonurgent or resource-heavy scripts. Start weekly on a pilot group and move to daily only for fixes where a day's delay costs you something.
Do Intune audit logs show what a remediation script did on a device?
No. They record changes to the package, such as create, update and assign actions. What the script did on the machine appears in local logs such as AgentExecutor.log and in your endpoint protection tooling, so use both when reviewing an incident.
Sources
- Use Remediations to detect and fix support issues, Microsoft Learn
- PowerShell scripts for Remediations, Microsoft Learn
- Device action: Run Remediation, Microsoft Learn
- What's new in Microsoft Intune, Microsoft Learn
- Audit, export or delete personal data collected by Intune, Microsoft Learn
- Use Microsoft Purview to manage data security and compliance for Microsoft 365 Copilot
- Detecting Intune lateral movement, IBM X-Force
- Intune Remediations: Detect and Fix Windows Issues at Scale
- Troubleshooting and Enhancing Logging for Intune Remediations
